#44669 [Opn->Bgs]: object not immediately destructed on error

From: Date: Tue, 08 Apr 2008 19:31:30 +0000
Subject: #44669 [Opn->Bgs]: object not immediately destructed on error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-124090@lists.php.net to get a copy of this message
ID: 44669 Updated by: felipe@php.net Reported By: ob dot php at daevel dot fr -Status: Open +Status: Bogus Bug Type: PDO related Operating System: Debian Lenny (testing) PHP Version: 5.2.5 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Previous Comments: ------------------------------------------------------------------------ [2008-04-08 19:14:29] crrodriguez at suse dot de This is the expected behaviuor, objects are destroyed at script shutdown. ------------------------------------------------------------------------ [2008-04-08 08:58:57] ob dot php at daevel dot fr 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 this bug report at http://bugs.php.net/?id=44669&edit=1

« previous php.bugs (#124090) next »