From: magic dot bitbucket at gmail dot com Operating system: GNU/Linux - Slackware 11 PHP version: 5.2.0 PHP Bug Type: Scripting Engine problem Bug description: __destruct doesn't get called on uncaught Exceptions
Description: ------------ When throwing an Exception and not catching it, Object destructors don't get called. I don't know if this is a bug or a feature, but surely it isn't expected behaviour and it isn't documented. This allows Objects to go out of scope without the destructor being called and makes destructors useless as cleanup has to be done manually before even thinking about throwing an Exception. Reproduce code: --------------- #!/usr/bin/php <?php class ExceptionTest { public function __construct(){} public function __destruct() { echo "hilfe mein leben!\n"; } } $test=new ExceptionTest(); throw new Exception('why are the destructors not called?', 666); ?> Expected result: ---------------- I would expect __destruct() to be called when throwing the Exception. Actual result: -------------- __destruct() isn't called. -- Edit bug report at http://bugs.php.net/?id=39706&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39706&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39706&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39706&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=39706&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=39706&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=39706&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=39706&r=needscript Try newer version: http://bugs.php.net/fix.php?id=39706&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=39706&r=support Expected behavior: http://bugs.php.net/fix.php?id=39706&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=39706&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=39706&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=39706&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39706&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=39706&r=dst IIS Stability: http://bugs.php.net/fix.php?id=39706&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=39706&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=39706&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=39706&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=39706&r=mysqlcfg