#31827 [Opn->Fbk]: Cannot catch multiple exceptions thrown during inclusion in __autoload()
| From: | tony2001@php.net | Date: | Wed, 30 Mar 2005 20:42:37 +0000 |
| Subject: | #31827 [Opn->Fbk]: Cannot catch multiple exceptions thrown during inclusion in __autoload() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-76078@lists.php.net to get a copy of this message | ||
ID: 31827
Updated by: tony2001@php.net
Reported By: mandersm at student dot ethz dot ch
-Status: Open
+Status: Feedback
Bug Type: Zend Engine 2 problem
Operating System: Fedora (Version n/a)
PHP Version: 5CVS-2005-02-03 (stable)
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.0-win32-latest.zip
Can't reproduce with the latest snapshot.
Previous Comments:
------------------------------------------------------------------------
[2005-02-03 13:17:36] mandersm at student dot ethz dot ch
Description:
------------
I tried to write a workaround for [no exceptions are allowed to 'raise
through' __autoload or a fatal error will occur,
http://bugs.php.net/bug.php?id=31816 ] by
catching every exception
thrown in __autoload.
This works fine except for: When multiple E_STRICT errors occur during
inclusion and get handled by some error handler which throws an
exception instead of displaying it, they can't get caught anymore,
causing a fatal error (thrown exception in __autoload).
- The E_STRICT errors are caused by the deprecated 'var $var' syntax.
- I suspect this bug(?) to apply to other PHP errors that cause a
thrown exception during inclusion. I couldn't verify this though
because i can't think of another error during inclusion that isn't
fatal.
- This does not occur when only one E_STRICT error exception gets
thrown.
- This is not reproducable without __autoload (by just trying to
include the file in {main}, catching the exception and seeing if an
unhandled one remains)
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'
Reproduce code:
---------------
File 'test.class.php':
<?php
class Test {
var $deprecated_var1;
var $deprecated_var2;
}
?>
File 'proof.php':
<?php
function error_handler($errno, $errstr) {
throw new Exception($errstr, $errno);
}
function __autoload($class_name) {
try {
include('test.class.php');
} catch (Exception $e) {
// handle it
}
}
set_error_handler('error_handler');
$test_class = new Test();
?>
Expected result:
----------------
No output at all. __autoload() should run smoothly since any exceptions
should get caught before returning, hence preventing a fatal error.
Actual result:
--------------
Fatal error: Function __autoload(Test) threw an exception of type
'Exception' in /home/smartloader/htdocs/proof.php on line 14
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31827&edit=1