|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47987 Autoload stops working if E_DEPRECATED occurs
Submitted: 2009-04-16 13:22 UTC Modified: 2013-10-03 16:37 UTC
Avg. Score:4.4 ± 0.7
Reproduced:12 of 12 (100.0%)
Same Version:5 (41.7%)
Same OS:8 (66.7%)
From: acecream1 at hotmail dot com Assigned: dmitry (profile)
Status: Closed Package: SPL related
PHP Version: 6CVS OS: *
Private report: No CVE-ID: None
 [2009-04-16 13:22 UTC] acecream1 at hotmail dot com
I use my custom error_handler and
when it is called i throw my custom exception which is being autoloaded using spl_autoload_register when first error occours.

This works normaly if Notice or Warning occours (did not test all the error types) but in case of E_DEPRECATED error the autoload is not called and i this reflects in a fatal error becouse my exception class does not exist.

Reproduce code:
1. spl_autoload_register(array($class, $method));
2. set_error_handler(array($this, 'handleError'));
3. Params\Store\Get::getInstance(&$_GET);

//Call-time pass-by-reference has been deprecated D:\www\lib\framework\Framework\Params.php on line 25

Expected result:
When E_DEPRECATED error would occour i would expect that all registered autoloaders would still function inside the error handler.

Actual result:
Fatal error: Class 'Framework\Error\Handler\Exception' not found in D:\www\lib\framework\Framework\Params.php on line 25


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-19 22:30 UTC]
I believe this is due to the fact that this specific error is 
triggered at compile time, not that it's a E_DEPRECATED. I'll check it 
 [2009-05-05 11:06 UTC]
Your error is triggered at compile-time, which disables autoload (and spl_autoload at the same time).

Won't be fixed for PHP5.3 as it may cause lots of other problems.
 [2012-06-28 14:40 UTC] thomas at weinert dot info
This happens if you include/eval() source. It works for other errors like E_STRICT or E_NOTICE.

Reproduce code:
function autoload($class) {
  echo "Autoloader for $class\n";
  eval('class '.$class.' {} ');

function error_handler($severity, $text, $file, $line, $context) {
  $class = 'TRIGGER_AUTOLOAD_'.$severity;
  $object = new $class();
  echo $text."\n";


eval('$object = &new stdClass();');

Expected result:

Autoloader for TRIGGER_AUTOLOAD_8192 
Deprecated: Assigning the return value of new by reference is deprecated

Actual result:

Fatal error: Class 'TRIGGER_AUTOLOAD_8192' not found in /<path>/bug47987.php(17) : eval()'d code on line 1
 [2013-10-03 16:37 UTC]
-Status: Assigned +Status: Closed
 [2013-10-03 16:37 UTC]
Fixed in PHP 5.4.21, see
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Sep 30 03:01:26 2023 UTC