Bug #73323 [Opn->Fbk]: Fatal errors not logged nor output when they occur in autoloaded file
| From: | nikic@php.net | Date: | Wed, 10 Jun 2020 10:27:11 +0000 |
| Subject: | Bug #73323 [Opn->Fbk]: Fatal errors not logged nor output when they occur in autoloaded file | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-227399@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73323&edit=1
ID: 73323
Updated by: nikic@php.net
Reported by: teo8976 at gmail dot com
Summary: Fatal errors not logged nor output when they occur
in autoloaded file
-Status: Open
+Status: Feedback
Type: Bug
Package: SPL related
Operating System: Linux
PHP Version: 5.6.26
Block user comment: N
Private report: N
New Comment:
I can't reproduce this. Parse error reporting in autoloaded files works as usual. There must be
something more complicated going on with the error handler than the example script indicates.
Previous Comments:
------------------------------------------------------------------------
[2016-10-14 16:00:29] teo8976 at gmail dot com
Description:
------------
I have all set up so as to output all errors.
the display_errors flag is On in the relevant .htaccess file, and error_reporting is set to E_ALL
& ~E_NOTICE & ~E_STRICT
Just to be clear: whenever there is a PARSE ERROR or a call to a non-existing function, or any other
kind of fatal error, anywhere in either the "entry" php file (the one called as a result
of the http request) or ANY of the included files included via include(), require(), include_once(),
require_once(), in all cases except the one I'll mention later, I usually get the fatal error
message in the very output to the browser, and also logged to Apache's error_log file.
However, when the exact same kind of non-runtime error (e.g. a trivial syntax error) is in a file
that is called via require() by a registered autoload function, registered via
spl_autoload_register(), then I get no error message whatsoever and I just get an undebuggable blank
page.
Additionally, the error is not even logged to Apache's error_log. So I waste days to find a
trivial syntax error.
Test script:
---------------
--- index.php ---
ini_set('unserialize_callback_func', 'spl_autoload_call');
spl_autoload_register(array('My_Autoloader', 'autoload'), true);
class My_Autoloader {
static function autoload($classname) {
$filename = //.... computes $filename from $classname
require_once($filename);
}
}
$instance = new MyClass();
--- /somewhere/MyClass.php ---
class MyClass {
lkandlnda ** SYNTAX ERROR HERE ** klsjdbklsj
}
Expected result:
----------------
Parse error: syntax error, unexpected end of file in /somewhere/MyClass.php on line 3
(or something like that)
Actual result:
--------------
no output, nothing logged
I can't stress this enough: if the exact same parse error is in the main file, or in a file
include()d or require()d in any other way than in an autoloader, then the error does show up in the
output AND in the logs.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73323&edit=1