php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41696 __destruct called twice
Submitted: 2007-06-15 06:28 UTC Modified: 2007-07-04 01:00 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: irik at future-proof dot net Assigned:
Status: No Feedback Package: Class/Object related
PHP Version: 5.2.3 OS: Linux (Slackware) 2.6.11.10
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-06-15 06:28 UTC] irik at future-proof dot net
Description:
------------
on linux (slackware) the __destruct method seems to be called twice, even before.  On windows32 this behaviour is not seen.  Perhaps I misunderstand the role of __destruct, but that would not explain why the behaviour differs between platforms.


Reproduce code:
---------------
$Test = new Test();
echo $Test->strtolower("foo bar") . "<br />";

class Test {

    	public function __construct() {
	}

	public function __call($function, $arguments) {
		return call_user_func_array($function, $arguments);
	}

	public function __destruct() {
		echo "here i am<br />";
	}

}

Expected result:
----------------
foo bar
here i am

Actual result:
--------------
here i am
foo bar
here i am

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-25 18:48 UTC] tony2001@php.net
Cannot reproduce.
 [2007-06-26 12:54 UTC] irik at future-proof dot net
'./configure' '--with-mysql' '--with-jpeg-dir' '--with-gd' '--with-png' '--enable-ftp' '--with-png-dir' '--with-apxs=/usr/local/apache/bin/apxs' '--with-zlib-dir' '--with-libxml2' '--with-openssl-dir' '--with-freetype-dir' '--enable-exif'

Apache/1.3.33 (Unix) PHP/5.2.3 mod_ssl/2.8.23 OpenSSL/0.9.8

I get the same result when run from command line as I do within the web server.

What else can I do or provide to help recreate this "bug"?  I have worked around the issue in my code but would still like to do what I can to get to the bottom of this very unusual behaviour.
 [2007-06-26 13:04 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows (zip):
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

For Windows (installer):

  http://snaps.php.net/win32/php5.2-win32-installer-latest.msi

Make sure you don't have any extensions which might modify PHPs behaviour (like Zend Optimizer, Xdebug etc).
 [2007-07-04 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 11:01:28 2024 UTC