From 16ff23a20d01439a3d642ebe8d891b0c6b6b42f4 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Fri, 14 Feb 2020 10:55:17 +0100 Subject: [PATCH] Fix #79271: DOMDocumentType::$childNodes is NULL Dom level 2 core, DOM level 3 core and the DOM living standard agree that `childNodes` always return a `NodeList`, and never `null`. --- ext/dom/node.c | 10 +++------- ext/dom/tests/bug69846.phpt | 4 ++-- ext/dom/tests/bug79271.phpt | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 ext/dom/tests/bug79271.phpt diff --git a/ext/dom/node.c b/ext/dom/node.c index 0e7f64a9bdb22..7d939bcde1d36 100644 --- a/ext/dom/node.c +++ b/ext/dom/node.c @@ -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; } diff --git a/ext/dom/tests/bug69846.phpt b/ext/dom/tests/bug69846.phpt index fcca4c06d6514..74662d53f690c 100644 --- a/ext/dom/tests/bug69846.phpt +++ b/ext/dom/tests/bug69846.phpt @@ -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 index 0000000000000..c0ef07bd61ca4 --- /dev/null +++ b/ext/dom/tests/bug79271.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #79271 (DOMDocumentType::$childNodes is NULL) +--SKIPIF-- + +--FILE-- +createDocumentType('html'); +var_dump($type->childNodes); +?> +--EXPECTF-- +object(DOMNodeList)#%d (1) { + ["length"]=> + int(0) +}