#45656 [Opn->Asn]: spl_autoload cannot handle exceptions

From: Date: Sun, 14 Sep 2008 11:57:59 +0000
Subject: #45656 [Opn->Asn]: spl_autoload cannot handle exceptions
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-128947@lists.php.net to get a copy of this message
ID: 45656 Updated by: colder@php.net Reported By: php at benjaminschulz dot com -Status: Open +Status: Assigned Bug Type: SPL related Operating System: * PHP Version: 5.3CVS-2008-07-29 (CVS) -Assigned To: +Assigned To: colder Previous Comments: ------------------------------------------------------------------------ [2008-07-29 15:30:47] php at benjaminschulz dot com Description: ------------ If spl_autoload() is triggered by class_exists() it is able to handle occuring exceptions but if it is triggered through "new .." then exceptions are silently ignored. Attached is an adapted copy of spl_autoload_012.phpt. Reproduce code: --------------- --TEST-- SPL: spl_autoload() capturing multiple Exceptions in __autoload --FILE-- <?php function autoload_first($name) { echo __METHOD__ . "\n"; throw new Exception('first'); } function autoload_second($name) { echo __METHOD__ . "\n"; throw new Exception('second'); } spl_autoload_register('autoload_first'); spl_autoload_register('autoload_second'); new ThisClassDoesNotExist; ?> ===DONE=== --EXPECTF-- autoload_first autoload_second Fatal error: Uncaught exception 'Exception' with message 'first' in %sspl_autoload_013.php:%d Stack trace: #0 [internal function]: autoload_first('ThisClassDoesNo...') #1 [internal function]: spl_autoload_call('ThisClassDoesNo...') #2 %sspl_autoload_013.php(%d): class_exists('ThisClassDoesNo...') #3 {main} Next exception 'Exception' with message 'second' in %sspl_autoload_013.php:%d Stack trace: #0 [internal function]: autoload_second('ThisClassDoesNo...') #1 [internal function]: spl_autoload_call('ThisClassDoesNo...') #2 %sspl_autoload_013.php(%d): class_exists('ThisClassDoesNo...') #3 {main} thrown in %sspl_autoload_013.php on line %d Actual result: -------------- autoload_first autoload_second PHP Fatal error: Class 'ThisClassDoesNotExist' not found in ... on line 0 Fatal error: Class 'ThisClassDoesNotExist' not found in ... on line 0 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45656&edit=1

« previous php.bugs (#128947) next »