diff --git a/ext/dom/document.c b/ext/dom/document.c index c6d0f723f89..dbbabb8bffd 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -986,7 +986,7 @@ PHP_METHOD(DOMDocument, getElementsByTagNameNS) xmlChar *local, *nsuri; id = ZEND_THIS; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &uri, &uri_len, &name, &name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!s", &uri, &uri_len, &name, &name_len) == FAILURE) { RETURN_THROWS(); } @@ -995,7 +995,7 @@ PHP_METHOD(DOMDocument, getElementsByTagNameNS) php_dom_create_iterator(return_value, DOM_NODELIST); namednode = Z_DOMOBJ_P(return_value); local = xmlCharStrndup(name, name_len); - nsuri = xmlCharStrndup(uri, uri_len); + nsuri = xmlCharStrndup(uri ? uri : "", uri_len); dom_namednode_iter(intern, 0, namednode, NULL, local, nsuri); } /* }}} end dom_document_get_elements_by_tag_name_ns */ diff --git a/ext/dom/element.c b/ext/dom/element.c index 317619001be..450d694c41d 100644 --- a/ext/dom/element.c +++ b/ext/dom/element.c @@ -933,7 +933,7 @@ PHP_METHOD(DOMElement, getElementsByTagNameNS) xmlChar *local, *nsuri; id = ZEND_THIS; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &uri, &uri_len, &name, &name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!s", &uri, &uri_len, &name, &name_len) == FAILURE) { RETURN_THROWS(); } @@ -942,7 +942,7 @@ PHP_METHOD(DOMElement, getElementsByTagNameNS) php_dom_create_iterator(return_value, DOM_NODELIST); namednode = Z_DOMOBJ_P(return_value); local = xmlCharStrndup(name, name_len); - nsuri = xmlCharStrndup(uri, uri_len); + nsuri = xmlCharStrndup(uri ? uri : "", uri_len); dom_namednode_iter(intern, 0, namednode, NULL, local, nsuri); } diff --git a/ext/dom/php_dom.stub.php b/ext/dom/php_dom.stub.php index cdc6b998469..b303caf93ff 100644 --- a/ext/dom/php_dom.stub.php +++ b/ext/dom/php_dom.stub.php @@ -190,7 +190,7 @@ class DOMElement implements DOMParentNode, DOMChildNode public function getElementsByTagName(string $qualifiedName) {} /** @return DOMNodeList */ - public function getElementsByTagNameNS(string $namespace, string $localName) {} + public function getElementsByTagNameNS(?string $namespace, string $localName) {} /** @return bool */ public function hasAttribute(string $qualifiedName) {} @@ -287,7 +287,7 @@ class DOMDocument implements DOMParentNode public function getElementsByTagName(string $qualifiedName) {} /** @return DOMNodeList */ - public function getElementsByTagNameNS(string $namespace, string $localName) {} + public function getElementsByTagNameNS(?string $namespace, string $localName) {} /** @return DOMNode|false */ public function importNode(DOMNode $node, bool $deep = false) {} diff --git a/ext/dom/php_dom_arginfo.h b/ext/dom/php_dom_arginfo.h index 844d2b91867..22944d296ca 100644 --- a/ext/dom/php_dom_arginfo.h +++ b/ext/dom/php_dom_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 7cba1a7a34cc4789871faf44fc4794a48db26e61 */ + * Stub hash: 72c2add8db9af8f90e84997a2a5ca6743268fae8 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_dom_import_simplexml, 0, 1, DOMElement, 1) ZEND_ARG_TYPE_INFO(0, node, IS_OBJECT, 0) @@ -184,10 +184,7 @@ ZEND_END_ARG_INFO() #define arginfo_class_DOMElement_getElementsByTagName arginfo_class_DOMElement_getAttribute -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMElement_getElementsByTagNameNS, 0, 0, 2) - ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, localName, IS_STRING, 0) -ZEND_END_ARG_INFO() +#define arginfo_class_DOMElement_getElementsByTagNameNS arginfo_class_DOMElement_getAttributeNS #define arginfo_class_DOMElement_hasAttribute arginfo_class_DOMElement_getAttribute @@ -292,7 +289,7 @@ ZEND_END_ARG_INFO() #define arginfo_class_DOMDocument_getElementsByTagName arginfo_class_DOMElement_getAttribute -#define arginfo_class_DOMDocument_getElementsByTagNameNS arginfo_class_DOMElement_getElementsByTagNameNS +#define arginfo_class_DOMDocument_getElementsByTagNameNS arginfo_class_DOMElement_getAttributeNS ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMDocument_importNode, 0, 0, 1) ZEND_ARG_OBJ_INFO(0, node, DOMNode, 0) diff --git a/ext/dom/tests/bug67474.phpt b/ext/dom/tests/bug67474.phpt index 953127fa0b1..16c2aad1524 100644 --- a/ext/dom/tests/bug67474.phpt +++ b/ext/dom/tests/bug67474.phpt @@ -6,13 +6,24 @@ require_once('skipif.inc'); ?> --FILE-- loadXML(''); $list = $doc->getElementsByTagNameNS('', 'a'); var_dump($list->length); $list = $doc->getElementsByTagNameNS(null, 'a'); var_dump($list->length); + +$elem = $doc->documentElement; +$list = $elem->getElementsByTagNameNS('', 'a'); +var_dump($list->length); +$list = $elem->getElementsByTagNameNS(null, 'a'); +var_dump($list->length); + ?> --EXPECT-- int(1) int(1) +int(1) +int(1)