From:             Martin dot Honnen at arcor dot de
Operating system: Windows XP
PHP version:      4.3.3
PHP Bug Type:     DOM XML related
Bug description:  Dom_Node->child_nodes() is not live as the W3C DOM specification 
demands

Description:
------------
The W3C DOM Level 2 specification at
  http://www.w3.org/TR/DOM-Level-2-Core/core.html#td-live
says about NodeList collections that they should be live, meaning

if a DOM user gets a NodeList object containing the children of an
Element, then subsequently adds more children to that element (or removes
children, or modifies them), those changes are automatically reflected in
the NodeList, without further action on the user's part.

However my test with PHP 4.3.3 and the following settings for DOMXML

DOM/XML         enabled
DOM/XML API Version     20020815
libxml Version  20507
HTML Support    enabled
XPath Support   enabled
XPointer Support        enabled
DOM/XSLT        enabled
libxslt Version         1.0.30
libxslt compiled against libxml Version         2.5.7

shows that the result returned from Node->child_nodes() is not live but
static.

Reproduce code:
---------------
<?php
function dumpDoc ($xmlDocument) {
  echo "<p><pre>\n";
  echo htmlentities($xmlDocument->dump_mem(true));
  echo "</pre></p>\n";
}
$xmlDocument = domxml_new_doc("1.0");
$rootElement = $xmlDocument->create_element("gods");
$xmlDocument->append_child($rootElement);
$childNodes = $rootElement->child_nodes();
echo 'count($childNodes): ' . count($childNodes) . "<br>\n";
$xmlDocument->append_child($rootElement);
for ($i = 0; $i < 5; $i++) {
  $god = $xmlDocument->create_element("god");
  $god->set_attribute("name", "god $i");
  $rootElement->append_child($god);
  dumpDoc($xmlDocument);
  echo 'count($childNodes): ' . count($childNodes) . "<br>\n";
}
?>

Expected result:
----------------
I would expect count($childNodes) to be incremented every time
$rootElement->append_child($god) is called. That is what the W3C DOM
understands to be a live collection, and that is what happens with
conformant DOM implementations (as the one in Mozilla or the one in SUN's
Java SDK 1.4).

Actual result:
--------------
The output with dump_mem shows that child elements are added but the
output of count($childNodes) is always 0.

-- 
Edit bug report at http://bugs.php.net/?id=25838&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=25838&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=25838&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=25838&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=25838&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=25838&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=25838&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=25838&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=25838&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=25838&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=25838&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=25838&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25838&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=25838&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=25838&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=25838&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=25838&r=float

Reply via email to