From:              bugzilla at malkusch dot de
Operating system: Debian Woody
PHP version:      5.0.0b2 (beta2)
PHP Bug Type:     Class/Object related
Bug description:  "__autoload threw an exception" during an uncaught Exception

Description:
------------
If I use __autoload() PHP says "__autoload threw an exception" while I
throw an exception which would be caught somewhere between several catch
statements.

That means __autoload() first loads the Class for the thrown Exception
then PHP searches a catch statement for the threwn  exception. The first
statement is for another Exception (the exception still is uncaught) so
__autoload should load this class. But here it fails and says "__autoload
threw an exception".

A Workaround would be to require all Exceptions for all catch Statements
before any exception is thrown.

Reproduce code:
---------------
// Be sure that Test1.php and Test2.php exists

function __autoload($className) {
    echo '<br>' . $className;
    require_once ucfirst($className) . '.php';
    echo 'loaded';
}

// If I would do "require_once Test1.php;" here
// everything would work

try {

    throw new Test2();

} catch(Test1 $e) {

} catch(Test2 $e) {

}

Expected result:
----------------
test2loaded
test1loaded

Actual result:
--------------
test2loaded
test1
Fatal error: __autoload threw an exception in
/home/malkusch/http/index.php on line 13

-- 
Edit bug report at http://bugs.php.net/?id=26591&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=26591&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=26591&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=26591&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=26591&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=26591&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=26591&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=26591&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=26591&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=26591&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=26591&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=26591&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=26591&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26591&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=26591&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=26591&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=26591&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26591&r=float

Reply via email to