ID: 36837
User updated by: tz at universale dot hu
Reported By: tz at universale dot hu
Status: Bogus
Bug Type: *General Issues
Operating System: Windows XP
PHP Version: 5.1.2
New Comment:
I double-checked the documentation and found nothing related to this
problem.
In a similar case, in the code i submit now, the destructor is _not_
called.
So, what is the difference?
Yours sincerely
tz
class foo {
function __construct(){
throw new Exception( "foomessage" );
}
function __destruct(){
sleep( 5 );
}
}
try {
$f = new foo();
} catch ( Exception $e ){
die;
}
Previous Comments:
------------------------------------------------------------------------
[2006-03-23 21:00:31] [EMAIL PROTECTED]
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
------------------------------------------------------------------------
[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