From: php at benjaminschulz dot com
Operating system: any
PHP version: 5.3CVS-2008-07-29 (CVS)
PHP Bug Type: SPL related
Bug description: spl_autoload cannot handle exceptions
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 bug report at http://bugs.php.net/?id=45656&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=45656&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=45656&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=45656&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45656&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=45656&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=45656&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=45656&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=45656&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=45656&r=support
Expected behavior: http://bugs.php.net/fix.php?id=45656&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=45656&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=45656&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45656&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45656&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45656&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=45656&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=45656&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=45656&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=45656&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=45656&r=mysqlcfg