ID: 25222
Updated by: [EMAIL PROTECTED]
Reported By: kevin at kevin-online dot com
-Status: Open
+Status: Closed
Bug Type: *Programming Data Structures
Operating System: Gentoo Linux (2.4.20-gentoo-r2)
PHP Version: 4.3.2
New Comment:
fixed in PHP 5. (won't fix in PHP 4)
Previous Comments:
------------------------------------------------------------------------
[2003-08-24 10:18:38] kevin at kevin-online dot com
Description:
------------
While building up a tree structure, i got strange troubles with some
broken references.
I used an array as stack holding references to objects. Some references
within the object were broken after using a reference returned by
array_pop.
PHP 4.3.2-r4
(Apache/1.3.28)
Reproduce code:
---------------
class Gnaa {
var $something;
var $name;
function Gnaa( $name ) { $this->name = $name;}
function setGnaa( &$something ) { $this->something = &$something; }
function &getGnaa() { return $something; }
}
$a =& new Gnaa("a");
$stack[] = &$a;
$b =& new Gnaa("b");
$stack[] = &$b;
$child = &array_pop($stack); // should be &$b
$child->setGnaa( &$a );
print_r($child); // output differs!
print_r( $b ); //
Expected result:
----------------
That $b has the reference to $a, because $child should be a reference
to $b.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25222&edit=1