#31816 [Opn->Bgs]: set_exception_handler() does not work for __autoload()

From: Date: Wed, 02 Feb 2005 15:03:08 +0000
Subject: #31816 [Opn->Bgs]: set_exception_handler() does not work for __autoload()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-73274@lists.php.net to get a copy of this message
ID: 31816 Updated by: derick@php.net Reported By: mandersm at student dot ethz dot ch -Status: Open +Status: Bogus Bug Type: Zend Engine 2 problem Operating System: Fedora (version n/a) PHP Version: 5.0.3 New Comment: 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 fatal errors can not be caught by your own error handler - no bug here. Previous Comments: ------------------------------------------------------------------------ [2005-02-02 15:54:36] mandersm at student dot ethz dot ch Description: ------------ When an exception gets thrown in __autoload() my custom error handler is ignored and a PHP uncaught exception fatal error is displayed instead. Additionally the occuring fatal error message is not as nice as a regular uncaught exception error would be (no trace). This bug *seems* to be related to http://bugs.php.net/bug.php?id=26591&edit=2 . I am still reporting it, since it still occurs with the latest snapshot version (20050202133, today 13:30) and is reproduced differently. My config line: './configure' '--with-xslt' '--enable-sockets' '--with-apxs2=/usr/local/apache2/bin/apxs' '--enable-fastcgi' '--with-libxml' '--with-openssl' '--enable-ftp' '--with-gd' '--with-pgsql=/usr/local/pgsql' '--with-zlib-dir=/usr/lib/' '--disable-cgi' '--disable-magic-quotes' '--with-jpeg-dir=/usr/lib/' '--with-dom' '--with-dom-xslt' '--with-mysql=/usr/local/mysql-standard-4.0.23-pc-linux-i686' No other special changes have been made. XDebug and APC are installed but *not* enabled in my php.ini. Reproduce code: --------------- <?php function my_handler($e) { echo 'My custom Handler: '.$e->getMessage().'<br/>'; } function regular_function() { throw new Exception('Regular function exception!'); } function __autoload($class_name) { throw new Exception('__autoload function exception!'); } set_exception_handler('my_handler'); /* attempt 1: */ regular_function(); /* attempt 2: */ $test = new Test(); // invoking __autoload() ?> Expected result: ---------------- attempt 1: 'My custom Handler: Regular function exception!' attempt 2: 'My custom Handler: __autoload function exception!' Actual result: -------------- attempt 1: 'My custom Handler: Regular function exception!' attempt 2: 'Fatal error: Function __autoload(Test) threw an exception of type 'Exception' in /home/smartloader/htdocs/proof.php on line 22' ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31816&edit=1

« previous php.bugs (#73274) next »