From:
Operating system: Debian GNU/Linux
PHP version: 5.3.8
Package: SPL related
Bug Type: Bug
Bug description:Implicit call to spl_autoload_call() does not throw exceptions
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 bug report at https://bugs.php.net/bug.php?id=60182&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=60182&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=60182&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=60182&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=60182&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=60182&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=60182&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=60182&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=60182&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=60182&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=60182&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=60182&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=60182&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=60182&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=60182&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=60182&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=60182&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=60182&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=60182&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=60182&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=60182&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=60182&r=mysqlcfg