php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29756 __destruct called twice with ze1_compatibility_mode = On
Submitted: 2004-08-19 14:16 UTC Modified: 2004-10-21 01:00 UTC
Votes:8
Avg. Score:4.1 ± 0.8
Reproduced:6 of 6 (100.0%)
Same Version:2 (33.3%)
Same OS:3 (50.0%)
From: hfuecks at phppatterns dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 5.0.1 OS: All
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: hfuecks at phppatterns dot com
New email:
PHP Version: OS:

 

 [2004-08-19 14:16 UTC] hfuecks at phppatterns dot com
Description:
------------
Using unmodified copy on php.ini-recommended (no extensions loaded etc.). Able to reproduce this problem with the Apache SAPI, CLI and CGI SAPIs.

With zend.ze1_compatibility_mode = On class destructors get called twice, once directly after the constructor.

With zend.ze1_compatibility_mode = Off (no other modifications to runtime) problem disappears (destructor called correctly).

This seems to have been reported before (not enough info): http://bugs.php.net/bug.php?id=27698

Have yet to confirm whether this in Windows specific (more from Linux when I get there...)

Reproduce code:
---------------
<?php
class Test {
	function __construct() {
		echo __METHOD__."\n";
	}

	function someMethod() {
		echo __METHOD__."\n";
	}

	function __destruct() {
		echo __METHOD__."\n";
		var_dump(debug_backtrace());
	}
}

$T = new Test();
$T->someMethod();
?>

Expected result:
----------------
Test::__construct
Test::someMethod
Test::__destruct
array(1) {
  [0]=>
  array(4) {
    ["function"]=>
    string(10) "__destruct"
    ["class"]=>
    string(4) "Test"
    ["type"]=>
    string(2) "::"
    ["args"]=>
    array(0) {
    }
  }
}

Actual result:
--------------
Test::__construct
Test::__destruct
array(2) {
  [0]=>
  array(5) {
    ["file"]=>
    string(20) "D:\php\test\test.php"
    ["line"]=>
    int(18)
    ["function"]=>
    string(10) "__destruct"
    ["class"]=>
    string(4) "Test"
    ["type"]=>
    string(2) "::"
  }
  [1]=>
  array(3) {
    ["file"]=>
    string(20) "D:\php\test\test.php"
    ["line"]=>
    int(18)
    ["function"]=>
    string(7) "unknown"
  }
}
Test::someMethod
Test::__destruct
array(1) {
  [0]=>
  array(4) {
    ["function"]=>
    NULL
    ["class"]=>
    string(4) "Test"
    ["type"]=>
    string(2) "::"
    ["args"]=>
    array(0) {
    }
  }
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-21 21:10 UTC] hfuecks at phppatterns dot com
Definately not specific to Windows; checked this out on Linux (Gentoo, 2.4 kernel, PHP 5.0.1) - exactly the same problem.
 [2004-08-21 21:14 UTC] hfuecks at phppatterns dot com
Updating OS to "All" (daringly)
 [2004-10-13 06:02 UTC] php at bobsilva dot com
This is fixed in 5.1 CVS
 [2004-10-13 09:23 UTC] derick@php.net
Please try using this CVS snapshot:

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


 [2004-10-21 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".
 [2006-06-28 19:45 UTC] crazyone at crazycoders dot net
I confirm that on PHP 5.1.4 for windows 2003, activating the compatibility with zend engine 4 calls the destructor right after calling the constructor which is obviously a bug if you can't turn off the compatibility feature (Like on multi hosting servers without correct configuration)

For me though, it seems fixed as soon as i turn off the compatibliity
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 11:01:30 2024 UTC