Edit report at https://bugs.php.net/bug.php?id=60182&edit=1
ID: 60182 Updated by: yohg...@php.net Reported by: pavel dot zubkou at gmail dot com Summary: Implicit call to spl_autoload_call() does not throw exceptions -Status: Open +Status: Closed Type: Bug Package: SPL related Operating System: Debian GNU/Linux PHP Version: 5.3.8 -Assigned To: +Assigned To: yohgaki Block user comment: N Private report: N New Comment: It seems fixed at least in 5.4 [yohgaki@dev PHP-5.4]$ ./php-bin -a Interactive shell php > echo 1290594600000 % 86400000; 378000 [yohgaki@dev PHP-5.4]$ ./php-bin <?php function autoload($class) { debug_print_backtrace(); throw new Exception('Test message'); } spl_autoload_register('autoload'); try { A::$someVariable; } catch (Exception $e) { echo $e->getMessage() . "\n"; } try { A::someMethod(); } catch (Exception $e) { echo $e->getMessage() . "\n"; } #0 autoload(A) #1 spl_autoload_call(A) called at [-:12] Test message #0 autoload(A) #1 spl_autoload_call(A) called at [-:18] Test message Previous Comments: ------------------------------------------------------------------------ [2011-11-07 12:09:09] francois dot dambrine at isen-lille dot fr As I run the test with 5.4b1 the result is : #0 autoload(A) #1 spl_autoload_call(A) called at [/home/isen/essai.php:12] Erreur de segmentation ------------------------------------------------------------------------ [2011-10-31 22:41:23] pavel dot zubkou at gmail dot com Description: ------------ Exceptions thrown from custom autoload function are not thrown outside the spl_autoload_call() function when it is implicitly called on expressions like 'A::someMethod();' and '$b = A::CONSTANT;', i.e. when accessing static methods and constants of the class. Test script: --------------- <?php function autoload($class) { debug_print_backtrace(); throw new Exception('Test message'); } spl_autoload_register('autoload'); try { A::$someVariable; } catch (Exception $e) { echo $e->getMessage() . "\n"; } try { A::someMethod(); } catch (Exception $e) { echo $e->getMessage() . "\n"; } Expected result: ---------------- #0 autoload(A) #1 spl_autoload_call(A) called at [/tmp/1.php:12] Test message #0 autoload(A) #1 spl_autoload_call(A) called at [/tmp/1.php:18] Test message Actual result: -------------- #0 autoload(A) #1 spl_autoload_call(A) called at [/tmp/1.php:12] Test message #0 autoload(A) #1 spl_autoload_call(A) called at [/tmp/1.php:18] PHP Fatal error: Class 'A' not found in /tmp/1.php on line 18 PHP Stack trace: PHP 1. {main}() /tmp/1.php:0 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60182&edit=1