]> granicus.if.org Git - php/commitdiff
Fix #79271: DOMDocumentType::$childNodes is NULL
authorChristoph M. Becker <cmbecker69@gmx.de>
Fri, 14 Feb 2020 09:55:17 +0000 (10:55 +0100)
committerChristoph M. Becker <cmbecker69@gmx.de>
Mon, 17 Feb 2020 08:07:54 +0000 (09:07 +0100)
Dom level 2 core, DOM level 3 core and the DOM living standard agree
that `childNodes` always return a `NodeList`, and never `null`.

NEWS
ext/dom/node.c
ext/dom/tests/bug69846.phpt
ext/dom/tests/bug79271.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index f8f131a800703293f7ef3e570f4197b27c747f5b..a80f373809924882de860ec83811cc09d2f3aa55 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ PHP                                                                        NEWS
 - DOM:
   . Fixed bug #77569: (Write Access Violation in DomImplementation). (Nikita,
     cmb)
+  . Fixed bug #79271 (DOMDocumentType::$childNodes is NULL). (cmb)
 
 - PCRE:
   . Fixed bug #79188 (Memory corruption in preg_replace/preg_replace_callback
index 0e7f64a9bdb22809e3f1d89dc339db4cfad4b776..7d939bcde1d36bda471583e0d893828479deb7e9 100644 (file)
@@ -428,13 +428,9 @@ int dom_node_child_nodes_read(dom_object *obj, zval *retval)
                return FAILURE;
        }
 
-       if (dom_node_children_valid(nodep) == FAILURE) {
-               ZVAL_NULL(retval);
-       } else {
-               php_dom_create_interator(retval, DOM_NODELIST);
-               intern = Z_DOMOBJ_P(retval);
-               dom_namednode_iter(obj, XML_ELEMENT_NODE, intern, NULL, NULL, NULL);
-       }
+       php_dom_create_interator(retval, DOM_NODELIST);
+       intern = Z_DOMOBJ_P(retval);
+       dom_namednode_iter(obj, XML_ELEMENT_NODE, intern, NULL, NULL, NULL);
 
        return SUCCESS;
 }
index fcca4c06d6514580e1d33b6e561258df562a0ce7..74662d53f690cb484637ba073b7c0fd7f6f5c320 100644 (file)
@@ -50,7 +50,7 @@ object(DOMText)#%d (19) {
   ["parentNode"]=>
   NULL
   ["childNodes"]=>
-  NULL
+  string(22) "(object value omitted)"
   ["firstChild"]=>
   NULL
   ["lastChild"]=>
@@ -140,7 +140,7 @@ object(DOMText)#%d (19) {
   ["parentNode"]=>
   NULL
   ["childNodes"]=>
-  NULL
+  string(22) "(object value omitted)"
   ["firstChild"]=>
   NULL
   ["lastChild"]=>
diff --git a/ext/dom/tests/bug79271.phpt b/ext/dom/tests/bug79271.phpt
new file mode 100644 (file)
index 0000000..c0ef07b
--- /dev/null
@@ -0,0 +1,17 @@
+--TEST--
+Bug #79271 (DOMDocumentType::$childNodes is NULL)
+--SKIPIF--
+<?php
+if (!extension_loaded('dom')) die('skip dom extension not available');
+?>
+--FILE--
+<?php
+$dom = new DOMImplementation();
+$type = $dom->createDocumentType('html');
+var_dump($type->childNodes);
+?>
+--EXPECTF--
+object(DOMNodeList)#%d (1) {
+  ["length"]=>
+  int(0)
+}