From:             mandersm at student dot ethz dot ch
Operating system: Fedora (Version n/a)
PHP version:      4CVS-2005-02-03 (stable)
PHP Bug Type:     Zend Engine 2 problem
Bug description:  Cannot catch multiple exceptions thrown during inclusion in 
__autoload()

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 bug report at http://bugs.php.net/?id=31827&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=31827&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=31827&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=31827&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=31827&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=31827&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=31827&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=31827&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=31827&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=31827&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=31827&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=31827&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=31827&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=31827&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=31827&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=31827&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=31827&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=31827&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=31827&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=31827&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=31827&r=mysqlcfg

Reply via email to