rrichards Sat Mar 18 11:46:13 2006 UTC Modified files: /php-src/ext/dom php_dom.c /php-src/ext/dom/tests bug36756.phpt Log: MFB51: Fixed bug #36756 (DOMDocument::removeChild corrupts node) add test http://cvs.php.net/viewcvs.cgi/php-src/ext/dom/php_dom.c?r1=1.90&r2=1.91&diff_format=u Index: php-src/ext/dom/php_dom.c diff -u php-src/ext/dom/php_dom.c:1.90 php-src/ext/dom/php_dom.c:1.91 --- php-src/ext/dom/php_dom.c:1.90 Thu Mar 16 10:33:23 2006 +++ php-src/ext/dom/php_dom.c Sat Mar 18 11:46:13 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_dom.c,v 1.90 2006/03/16 10:33:23 dmitry Exp $ */ +/* $Id: php_dom.c,v 1.91 2006/03/18 11:46:13 rrichards Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -306,6 +306,8 @@ if (obj->prop_handler != NULL) { ret = zend_u_hash_find(obj->prop_handler, Z_TYPE_P(member), Z_UNIVAL_P(member), Z_UNILEN_P(member)+1, (void **) &hnd); + } else if (instanceof_function(obj->std.ce, dom_node_class_entry TSRMLS_CC)) { + php_error(E_WARNING, "Couldn't fetch %s. Node no longer exists", obj->std.ce->name); } if (ret == SUCCESS) { ret = hnd->read_func(obj, &retval TSRMLS_CC); http://cvs.php.net/viewcvs.cgi/php-src/ext/dom/tests/bug36756.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/dom/tests/bug36756.phpt diff -u /dev/null php-src/ext/dom/tests/bug36756.phpt:1.2 --- /dev/null Sat Mar 18 11:46:13 2006 +++ php-src/ext/dom/tests/bug36756.phpt Sat Mar 18 11:46:13 2006 @@ -0,0 +1,35 @@ +--TEST-- +Bug #36756: (DOMDocument::removeChild corrupts node) +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +/* Node is preserved from removeChild */ +$dom = new DOMDocument(); +$dom->loadXML('<root><child/></root>'); +$xpath = new DOMXpath($dom); +$node = $xpath->query('/root')->item(0); +echo $node->nodeName . "\n"; +$dom->removeChild($GLOBALS['dom']->firstChild); +echo "nodeType: " . $node->nodeType . "\n"; + +/* Node gets destroyed during removeChild */ +$dom->loadXML('<root><child/></root>'); +$xpath = new DOMXpath($dom); +$node = $xpath->query('//child')->item(0); +echo $node->nodeName . "\n"; +$GLOBALS['dom']->removeChild($GLOBALS['dom']->firstChild); + +echo "nodeType: " . $node->nodeType . "\n"; + +?> +--EXPECTF-- +root +nodeType: 1 +child + +Warning: Couldn't fetch DOMElement. Node no longer exists in %sbug36756.php on line %d + +Notice: Undefined property: DOMElement::$nodeType in %sbug36756.php on line %d +nodeType:
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php