From: Operating system: Linux, FreeBSD PHP version: 5.3.10 Package: SPL related Bug Type: Bug Bug description:SPL autoload issues Fatal Error if a handler throws exception
Description: ------------ If a handler is registered for autoloading (whether via spl_autoload_register() or __autoload()) and it throws an exception when a class is not found, the exception can not be caught as usual if a method of the target class is statically called. Instead, a Fatal Error: Class not found is issued (which is quite what the autoloader is meant to avoid!) Yet, when, e.g. trying to access a static field of that class, the exceptions get caught correctly. Tested on several PHP versions (5.3.3 - 5.3.10) on Linux and FreeBSD. Test script: --------------- <? function x($class) { print "xxx\n"; // gets printed throw new Exception("Class '{$class}' not found"); } spl_autoload_register('x'); try { $a = A::z(); // FATAL ERROR: class 'A' not found // NOTE: // $a = A::$z; - will be correctly caught } catch (Exception $ex) { print "{$ex}\n"; // never gets executed } Expected result: ---------------- xxx exception 'Exception' with message 'Class 'A' not found' in <FILE>:5 --- this is what gets output in case the exception is caught Actual result: -------------- xxx Fatal error: Class 'A' not found in <FILE> on line 10 -- Edit bug report at https://bugs.php.net/bug.php?id=61442&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=61442&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=61442&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=61442&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=61442&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=61442&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=61442&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=61442&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=61442&r=needscript Try newer version: https://bugs.php.net/fix.php?id=61442&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=61442&r=support Expected behavior: https://bugs.php.net/fix.php?id=61442&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=61442&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=61442&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=61442&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=61442&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=61442&r=dst IIS Stability: https://bugs.php.net/fix.php?id=61442&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=61442&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=61442&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=61442&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=61442&r=mysqlcfg