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

From: Date: Tue, 08 Apr 2008 19:14:30 +0000
Subject: #44669 [Com]: object not immediately destructed on error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-124089@lists.php.net to get a copy of this message
ID: 44669 Comment by: crrodriguez at suse dot de Reported By: ob dot php at daevel dot fr Status: Open Bug Type: PDO related Operating System: Debian Lenny (testing) PHP Version: 5.2.5 New Comment: This is the expected behaviuor, objects are destroyed at script shutdown. Previous Comments: ------------------------------------------------------------------------ [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 (#124089) next »