Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > #36837 : construct, call another classes fn, throw,catch,die. destructor is called
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 26th May 17:53
php-bugs
External User
 
Posts: 1
Default #36837 : construct, call another classes fn, throw,catch,die. destructor is called



From: tz at universale dot hu
Operating system: Windows XP
PHP version: 5.1.2
PHP Bug Type: *General Issues
Bug description: construct, call another classes fn, throw,catch,die. destructor is called

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 bug report at http://bugs.php.net/?id=36837&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36837&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36837&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36837&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=36837&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=36837&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=36837&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=36837&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=36837&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=36837&r=support
Expected behavior: http://bugs.php.net/fix.php?id=36837&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=36837&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=36837&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=36837&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36837&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=36837&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=36837&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=36837&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=36837&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=36837&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=36837&r=mysqlcfg
  Reply With Quote


  sponsored links


2 26th May 17:53
External User
 
Posts: 1
Default #36837 : construct, call another classes fn, throw,catch,die. destructor is called



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 do***entation 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
  Reply With Quote
3 26th May 17:53
php-bugs
External User
 
Posts: 1
Default #36837 : construct, call another classes fn, throw,catch,die. destructor is called


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 do***entation 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] bjori@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the do***entation 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
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666