php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73323 Fatal errors not logged nor output when they occur in autoloaded file
Submitted: 2016-10-14 16:00 UTC Modified: 2020-06-21 04:22 UTC
From: teo8976 at gmail dot com Assigned:
Status: No Feedback Package: SPL related
PHP Version: 5.6.26 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
39 + 13 = ?
Subscribe to this entry?

 
 [2016-10-14 16:00 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-06-10 10:27 UTC] nikic@php.net
-Status: Open +Status: Feedback
 [2020-06-10 10:27 UTC] nikic@php.net
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.
 [2020-06-21 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 08:01:29 2024 UTC