#44669 [NEW]: object not immediately destructed on error

From: Date: Tue, 08 Apr 2008 08:58:57 +0000
Subject: #44669 [NEW]: object not immediately destructed on error
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-124070@lists.php.net to get a copy of this message
From: ob dot php at daevel dot fr Operating system: Debian Lenny (testing) PHP version: 5.2.5 PHP Bug Type: PDO related Bug description: object not immediately destructed on error Description: ------------ Hello, when catching a connection error in a class extending PDO, the object is not destroyed before end of script. It's really not a big bug, but as the instance is not usable (no instance is returned at all) it should be destroyed no ? Reproduce code: --------------- <?php class PDOtest extends PDO { public function __construct( $dsn, $user, $password ) { try { parent::__construct( $dsn, $user, $password ); } catch( PDOException $e ) { echo 'there is an error... but continue the script', PHP_EOL; return; } } public function __destruct() { echo 'DESTRUCT', PHP_EOL; } } echo 'CONSTRUCT', PHP_EOL; $test = new PDOtest( 'mysql:host=localhost;dbname=test', 'baduser', 'orpass' ); var_dump( $test ); echo 'SOME WORKS', PHP_EOL; ?> Expected result: ---------------- CONSTRUCT there is an error... but continue the script DESTRUCT NULL SOME WORKS Actual result: -------------- CONSTRUCT there is an error... but continue the script NULL SOME WORKS DESTRUCT -- Edit bug report at http://bugs.php.net/?id=44669&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44669&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44669&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44669&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44669&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44669&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44669&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44669&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44669&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44669&r=support Expected behavior: http://bugs.php.net/fix.php?id=44669&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44669&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44669&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44669&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44669&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44669&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44669&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44669&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44669&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44669&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44669&r=mysqlcfg

« previous php.bugs (#124070) next »