xref: /php-src/ext/dom/tests/bug36756.phpt (revision 003ebdd0)
1--TEST--
2Bug #36756 (DOMDocument::removeChild corrupts node)
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8/* Node is preserved from removeChild */
9$dom = new DOMDocument();
10$dom->loadXML('<root><child/></root>');
11$xpath = new DOMXpath($dom);
12$node = $xpath->query('/root')->item(0);
13echo $node->nodeName . "\n";
14$dom->removeChild($GLOBALS['dom']->firstChild);
15echo "nodeType: " . $node->nodeType . "\n";
16/* Node gets destroyed during removeChild */
17$dom->loadXML('<root><child/></root>');
18$xpath = new DOMXpath($dom);
19$node = $xpath->query('//child')->item(0);
20echo $node->nodeName . "\n";
21$GLOBALS['dom']->removeChild($GLOBALS['dom']->firstChild);
22
23echo "nodeType: " . $node->nodeType . "\n";
24
25?>
26--EXPECT--
27root
28nodeType: 1
29child
30nodeType: 1
31