PHP Fatal Error log – referer

apache-2.2magentoPHP

I have the following log entry:

[Thu Oct 11 01:02:03 2012] [error] [client 127.0.0.1] PHP Fatal error:  Class 'Mage' not found in /var/www/foo/bar/Mage/Core/functions.php on line 244, referer: http://example.com/de/checkout/cart/

Is the referer shown in this message really the HTTP referer or actually the URL where the error happend?

Best Answer

Referer = HTTP_REFERER

The referer entry in the error log really referes to the page referring to the script (HTTP_REFERER) and not the script where the error actually happend.

Verification

I just tried it by creating a file foo.html with a hyperlink to a file foo.php

The content of `foo.php

<?php

foobar();

What I get in the Apache error log is:

PHP Fatal error:  Call to undefined function foobar() in /var/www/foo.php on line 3, referer: http://localhost/foo.html

How to find out which script caused the error

If the error is nested deep inside an PHP app, the .php file name mentioned would not be identical with the request URI. To find out the request that caused the error, we can look in the access.log and try to find an entry with the same or similar time and date (it looks that even the time and date can differ, depending on execution time)