Skip to content

Commit 0966941

Browse files
committed
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`.
1 parent 392dada commit 0966941

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ PHP NEWS
1212
- DOM:
1313
. Fixed bug #77569: (Write Access Violation in DomImplementation). (Nikita,
1414
cmb)
15+
. Fixed bug #79271 (DOMDocumentType::$childNodes is NULL). (cmb)
1516

1617
- PCRE:
1718
. Fixed bug #79188 (Memory corruption in preg_replace/preg_replace_callback

ext/dom/node.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,13 +428,9 @@ int dom_node_child_nodes_read(dom_object *obj, zval *retval)
428428
return FAILURE;
429429
}
430430

431-
if (dom_node_children_valid(nodep) == FAILURE) {
432-
ZVAL_NULL(retval);
433-
} else {
434-
php_dom_create_interator(retval, DOM_NODELIST);
435-
intern = Z_DOMOBJ_P(retval);
436-
dom_namednode_iter(obj, XML_ELEMENT_NODE, intern, NULL, NULL, NULL);
437-
}
431+
php_dom_create_interator(retval, DOM_NODELIST);
432+
intern = Z_DOMOBJ_P(retval);
433+
dom_namednode_iter(obj, XML_ELEMENT_NODE, intern, NULL, NULL, NULL);
438434

439435
return SUCCESS;
440436
}

ext/dom/tests/bug69846.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ object(DOMText)#%d (19) {
5050
["parentNode"]=>
5151
NULL
5252
["childNodes"]=>
53-
NULL
53+
string(22) "(object value omitted)"
5454
["firstChild"]=>
5555
NULL
5656
["lastChild"]=>
@@ -140,7 +140,7 @@ object(DOMText)#%d (19) {
140140
["parentNode"]=>
141141
NULL
142142
["childNodes"]=>
143-
NULL
143+
string(22) "(object value omitted)"
144144
["firstChild"]=>
145145
NULL
146146
["lastChild"]=>

ext/dom/tests/bug79271.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Bug #79271 (DOMDocumentType::$childNodes is NULL)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('dom')) die('skip dom extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
$dom = new DOMImplementation();
10+
$type = $dom->createDocumentType('html');
11+
var_dump($type->childNodes);
12+
?>
13+
--EXPECTF--
14+
object(DOMNodeList)#%d (1) {
15+
["length"]=>
16+
int(0)
17+
}

0 commit comments

Comments
 (0)