Edit report at http://bugs.php.net/bug.php?id=52640&edit=1

 ID:                 52640
 Updated by:         rricha...@php.net
 Reported by:        ken at smallboxcms dot com
 Summary:            Odd Garbage collection Behaviour with Dom Node
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            DOM XML related
 Operating System:   Linux
 PHP Version:        5.3.3
 Block user comment: N
 Private report:     N

 New Comment:

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

DOM objects are just wrappers to underlying libxml2 structures and
unless directly 

referenced, i.e. $blah->node = $node, the $node object is no longer
referenced 

outside of the function. Appending the node appends the libxml2 node
structure to 

the underlying xml tree, does nothing in respect to the DOM object
wrapper.


Previous Comments:
------------------------------------------------------------------------
[2010-08-19 00:32:30] ken at smallboxcms dot com

Description:
------------
Variables added to dom nodes are later unset. This behaviour does not
appear to happen with other types of PHP objects. 

Test script:
---------------
<?php



$blah = new stdClass;

function humbug()

{

/* Behaviour changes when uncommented. Think this is a GC bug.

    global $node;

*/



    global $blah;

    $doc = new domDocument('1.0', 'utf-8');

    $blah->doc = $doc;

    $node = $doc->createElement('node');

    $doc->appendChild($node);



    $node->foo = true;



    $obj = new stdClass;

    $blah->obj = $obj;

    $obj->child = new stdClass;

    $obj->child->foo = true;

}



humbug();

echo "Should be set: ".$blah->doc->firstChild->foo."<BR>\n";

echo "Is Set: ".$blah->obj->child->foo."<BR>\n";



?>

Expected result:
----------------
I would expect that $blah->doc->firstChild->foo would be set after the
function call. 



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52640&edit=1

Reply via email to