#36837 [Opn->Bgs]: construct, call another classes fn, throw,catch,die. destructor is called

From: Date: Thu, 23 Mar 2006 20:00:32 +0000
Subject: #36837 [Opn->Bgs]: construct, call another classes fn, throw,catch,die. destructor is called
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-94819@lists.php.net to get a copy of this message
ID: 36837 Updated by: bjori@php.net Reported By: tz at universale dot hu -Status: Open +Status: Bogus Bug Type: *General Issues Operating System: Windows XP PHP Version: 5.1.2 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 the destructor is called during the script shutdown Previous Comments: ------------------------------------------------------------------------ [2006-03-23 20:47:12] tz at universale dot hu Description: ------------ Normally, if the constructor throws an exception, the destructor is not called reaching the end of the script. That's OK In the code attached, the destructor is called. There are two important parts of the code: 1. The exception must be generated by an object called from the foo's constructor. 2. It has to handle this exception, and call 'die' In this case, the foo-s destructor is called. Reproduce code: --------------- class foo { function __construct(){ new thrower( this ); } function __destruct(){ sleep( 5 ); } } class thrower { function __construct(){ try { throw new Exception( "foomessage" ); } catch ( Exception $e ){ die; } } } $f = new foo(); Expected result: ---------------- the destructor mustn't be called ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36837&edit=1

« previous php.bugs (#94819) next »