#27903 [Bgs]: Undesired behavior of class destructor
| From: | schroeter at liquidvision dot net | Date: | Wed, 07 Apr 2004 13:11:29 +0000 |
| Subject: | #27903 [Bgs]: Undesired behavior of class destructor | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-57696@lists.php.net to get a copy of this message | ||
ID: 27903
User updated by: schroeter at liquidvision dot net
Reported By: schroeter at liquidvision dot net
Status: Bogus
Bug Type: Class/Object related
Operating System: Winn2000 Server
PHP Version: 5.0.0RC1
New Comment:
Anyways,
1. I disagree that this behavior is the way it should be. It does not
make sense to me that internal stuff is cleaned up before the user
defined stuff is?!
2. If it will remain this way, it has to made clear in the docs.
3. I found a workaround that will solve this:
just place a
register_shutdown_function(array(&$this, 'your class function'));
at the end of the __constructor function -this will give the desired
functionality.
I hope that will remain in future releases.
Thanks,
Tom
Previous Comments:
------------------------------------------------------------------------
[2004-04-07 09:11:01] derick@php.net
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
This is correct behavior, nothing we can fix most likely here for PHP
5.0.
------------------------------------------------------------------------
[2004-04-07 07:57:43] sniper@php.net
You need to redesign your stuff, the destructor works just fine. (don't
misuse it like you did)
------------------------------------------------------------------------
[2004-04-07 07:04:36] schroeter at liquidvision dot net
Description:
------------
The __destruct() method seems buggy as the destructor is called after
some system internals are already cleaned up (e.g. mysql extension,
session etc.).
Thus it is impossible to set e.g. session data in the destructor,
leaving this mostly superfluous!
I have prepared an example that shows the point in detail.
This is also true for e.g. mysql_close() in the destructor!
Reproduce code:
---------------
http://www.liquidvision.net/tomimg/php/destruct.php5
Expected result:
----------------
Please see comments in file.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27903&edit=1