From: bran...@php.net Operating system: Irrelevent PHP version: 5.3.1 PHP Bug Type: SPL related Bug description: Exceptions can be thrown and caught in an autoload function
Description: ------------ According to the PHP documentation, exceptions cannot be thrown inside __autoload() functions, and prior to PHP 5.3, exceptions thrown resulted in fatal errors. Since PHP 5.3, it has been possible to throw and catch exceptions from __autoload() functions. I'm happy to chalk this up to a documentation bug, and if it is I will gladly fix it myself; however, I want to make sure this is intended functionality and not an accidental inclusion that might be fixed in future versions of PHP. Reproduce code: --------------- <?php function autoload($class) { throw new Exception('test'); require $class . '.php'; } spl_autoload_register('autoload'); try { new NoExist(); } catch (Exception $e) { echo 'unable to load the class.'; } Expected result: ---------------- Fatal error, as the autoloader throws an exception which is not allowed. Actual result: -------------- string of "unable to load the class." -- Edit bug report at http://bugs.php.net/?id=50250&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50250&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50250&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50250&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=50250&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50250&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=50250&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=50250&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=50250&r=needscript Try newer version: http://bugs.php.net/fix.php?id=50250&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=50250&r=support Expected behavior: http://bugs.php.net/fix.php?id=50250&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=50250&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=50250&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=50250&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50250&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=50250&r=dst IIS Stability: http://bugs.php.net/fix.php?id=50250&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=50250&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=50250&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=50250&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=50250&r=mysqlcfg