ID: 28892 Updated by: [EMAIL PROTECTED] -Summary: Object id that's still in use gets reassigned Reported By: paranoid at pcwereld dot be -Status: Open +Status: Verified Bug Type: Zend Engine 2 problem -Operating System: Windows 2k +Operating System: All -PHP Version: 5.0.0RC3 +PHP Version: 5.0.0+ New Comment:
Shorter reproduce script. It shows that removing one reference with setting the variable holding it to NULL deletes the object thus leaving one reference handing. In the script of the original reporter this interferes with a creation of a new object of the class of the innormally deleted one and the new objects hooks on the nirvana reference created by the bug. <?php new C(new A("FUBAR")); class A { public $text; function __construct($m){ $this->text = $m; } } class C { public $e; public $e2; function __construct($elem){ $this->e = $elem; $this->e2 = $elem; $this->e = null; var_dump($this); } } ?> Output : object(C)#1 (2) { ["e"]=> NULL ["e2"]=> NULL } // "e2" has been deleted when $this->e =null; which is not correct IMHO Similar example works correctly : php -r '$a=new stdclass();$b=$a; $a=null; var_dump($a,$b);' Previous Comments: ------------------------------------------------------------------------ [2004-06-24 10:38:27] paranoid at pcwereld dot be When using new C($a = new A()) instead of new C(new A()) the code seems to work like expected. ------------------------------------------------------------------------ [2004-06-23 12:59:04] paranoid at pcwereld dot be Description: ------------ PHP reassigns an allready-in-use object id to a newly created object, after the first object (that loses it's id) was removed from an array, but was still referenced in another object. Reproduce code: --------------- http://users.pandora.be/paranet/poc.html Expected result: ---------------- I expected that object C would still contain a reference to the first A object (A-1) i created, ... Actual result: -------------- (see comments in code for the actual output) ... instead A-1 was overwritten with a second A object (A-2) i created, that (!!!!!) used the same object id as the first A object. PHP seems to be missing the fact that A-1 is still referenced inside the C object, and thus assigns the object id A-1 was using to A-2 Removing the part marked "important" in list_remove results in a normal behaviour, eg. C refers to A-1, not A-2. And A-2 doesn't get the same object id as A-1. The bug is probably somewhere in the code that removes an object from an array. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28892&edit=1