php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31827 Cannot catch multiple exceptions thrown during inclusion in __autoload()
Submitted: 2005-02-03 13:17 UTC Modified: 2005-04-08 14:45 UTC
Votes:3
Avg. Score:3.7 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (33.3%)
From: mandersm at student dot ethz dot ch Assigned: helly (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.0.3 OS: *
Private report: No CVE-ID: None
 [2005-02-03 13:17 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-30 22:42 UTC] tony2001@php.net
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.
 [2005-04-07 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2005-04-08 14:45 UTC] helly@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 18 20:01:27 2024 UTC