From: tyrael Operating system: linux PHP version: 5.4.17 Package: SPL related Bug Type: Bug Bug description:spl autoload won't work inside an autoload
Description: ------------ I just bumped into an issue, where we had a Strict error triggered about an abstract class, which caused our autoloader to fail. It seems that the autoloader won't be called when you try to reference a not-yet- loaded class from an error handler triggered by an autoloader function. I think that the attached test script makes the scenario more clear(sorry for the eval part, I didn't wanted to upload multiple scripts), but feel free to ask me if you need more info. ps: it seems that this never worked http://3v4l.org/AQCue but I couldn't find any previous reports or notes/docs on the topic. Test script: --------------- <?php spl_autoload_register(function($class){ if ($class == 'MyConcrete') { eval(' class MyConcrete extends MyAbstract { public static function createInstance() {} } '); } elseif ($class == 'MyAbstract') { eval(' abstract class MyAbstract { public abstract static function createInstance(); } '); } else { eval('class '.$class.'{}'); } }); set_error_handler(function($errno, $errstr, $errfile, $errline){ $myclass = new MyClass; }); $concrete = new MyConcrete; $myclass = new MyClass; Expected result: ---------------- trigger the autoloader from the error handler and load the class Actual result: -------------- Fatal error: Class 'MyClass' not found in index.php(14) : eval()'d code on line 3 -- Edit bug report at https://bugs.php.net/bug.php?id=65317&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65317&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=65317&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65317&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=65317&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=65317&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=65317&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=65317&r=needscript Try newer version: https://bugs.php.net/fix.php?id=65317&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=65317&r=support Expected behavior: https://bugs.php.net/fix.php?id=65317&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=65317&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=65317&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=65317&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65317&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=65317&r=dst IIS Stability: https://bugs.php.net/fix.php?id=65317&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=65317&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=65317&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=65317&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=65317&r=mysqlcfg