Edit report at https://bugs.php.net/bug.php?id=65317&edit=1
ID: 65317 Updated by: larue...@php.net Reported by: tyr...@php.net Summary: spl autoload won't work inside an autoload Status: Open Type: Bug Package: SPL related Operating System: linux PHP Version: 5.4.17 Block user comment: N Private report: N New Comment: Hey, it should be a intention behavior: zend_class_entry *zend_fetch_class_by_name(const char *class_name, uint class_name_len, const zend_literal *key, int fetch_type TSRMLS_DC) /* {{{ */ { zend_class_entry **pce; int use_autoload = (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) == 0; it seems try to prevent some recursive autoload, then stack overflow so.... won't fix IMO (it's really a edge case :)) maybe document it instead? thanks Previous Comments: ------------------------------------------------------------------------ [2013-07-23 16:26:52] tyr...@php.net 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 this bug report at https://bugs.php.net/bug.php?id=65317&edit=1