Skip to content

Fix #79271: DOMDocumentType::$childNodes is NULL #5180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions ext/dom/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, what's an "interator"?

intern = Z_DOMOBJ_P(retval);
dom_namednode_iter(obj, XML_ELEMENT_NODE, intern, NULL, NULL, NULL);

return SUCCESS;
}
Expand Down
4 changes: 2 additions & 2 deletions ext/dom/tests/bug69846.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object(DOMText)#%d (19) {
["parentNode"]=>
NULL
["childNodes"]=>
NULL
string(22) "(object value omitted)"
["firstChild"]=>
NULL
["lastChild"]=>
Expand Down Expand Up @@ -140,7 +140,7 @@ object(DOMText)#%d (19) {
["parentNode"]=>
NULL
["childNodes"]=>
NULL
string(22) "(object value omitted)"
["firstChild"]=>
NULL
["lastChild"]=>
Expand Down
17 changes: 17 additions & 0 deletions ext/dom/tests/bug79271.phpt
Original file line number Diff line number Diff line change
@@ -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)
}