ID: 31102 User updated by: php_nospam at ramihyn dot sytes dot net Reported By: php_nospam at ramihyn dot sytes dot net Status: Bogus Bug Type: Zend Engine 2 problem Operating System: Windows 2000 SP4 PHP Version: 5.0.2 New Comment:
Your statement about that "last resort" is *not* documented. The Zend Engine 2 changes list says: The __autoload() interceptor function will be automatically called when an undeclared class is to be instantiated. The name of that class will be passed to the __autoload() interceptor function as its only argument. What __autoload() does is breaking the Exception handling, so I consider this as a bug. Previous Comments: ------------------------------------------------------------------------ [2004-12-16 12:28:12] php_nospam at ramihyn dot sytes dot net Maybe you should rename the function to __lastresort() ;-) __autoload() sounds like autorun to me. ------------------------------------------------------------------------ [2004-12-15 23:59:35] php_nospam at ramihyn dot sytes dot net Also notice: the message isn't "Class 'Bug' not found" but an unhandled exception. ------------------------------------------------------------------------ [2004-12-15 23:38:04] php_nospam at ramihyn dot sytes dot net Correction: this does *not* happen when i throw an exception inside __construct(), in this case its also handled correctly. ------------------------------------------------------------------------ [2004-12-15 22:41:11] [EMAIL PROTECTED] Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php __autoload is the last resort for the engine if it is looking for a class. If it can not be found it is seen as a fatal error (ie \"class not found\") and the script is aborted. This also happens when you throw an exception to signal that the class could not be loaded. ------------------------------------------------------------------------ [2004-12-15 21:07:30] php_nospam at ramihyn dot sytes dot net Description: ------------ The code below prints a fatal error. This is incorrect as the throwing of the exception is supposed to bring us immediately to the catch block. Its also inconsistent because when i replace the $bug = new Bug(); by __autoload("Bug"); the exception is handled correctly. Code following the throw is not executed, as expected. Reproduce code: --------------- function __autoload($class) { throw new Exception(); } try { $bug = new Bug(); // Results in a fatal error #__autoload("Bug"); // Prints "exception caught." } catch (Exception $e) { echo "exception caught."; } Expected result: ---------------- exception caught. Actual result: -------------- Fatal error: Function __autoload(Bug) threw an exception of type 'Exception' in D:\y\index.php on line 7 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31102&edit=1