diff --git a/ext/dom/element.c b/ext/dom/element.c index 44c576a07363f..0a4e0c3ec847f 100644 --- a/ext/dom/element.c +++ b/ext/dom/element.c @@ -862,7 +862,7 @@ PHP_METHOD(DOMElement, setAttributeNodeNS) nsp = attrp->ns; if (nsp != NULL) { - existattrp = xmlHasNsProp(nodep, nsp->href, attrp->name); + existattrp = xmlHasNsProp(nodep, attrp->name, nsp->href); } else { existattrp = xmlHasProp(nodep, attrp->name); } diff --git a/ext/dom/tests/setAttributeNodeNS_same_uri_different_prefix.phpt b/ext/dom/tests/setAttributeNodeNS_same_uri_different_prefix.phpt new file mode 100644 index 0000000000000..622b586cea846 --- /dev/null +++ b/ext/dom/tests/setAttributeNodeNS_same_uri_different_prefix.phpt @@ -0,0 +1,38 @@ +--TEST-- +setAttributeNodeNS with same URI but different prefix +--EXTENSIONS-- +dom +--FILE-- +appendChild($doc->createElement('container')); +$attribute = $doc->createAttributeNS('http://php.net/ns1', 'foo:hello'); +$attribute->nodeValue = '1'; +var_dump($doc->documentElement->setAttributeNodeNS($attribute)?->nodeValue); +echo $doc->saveXML(), "\n"; +$attribute = $doc->createAttributeNS('http://php.net/ns1', 'bar:hello'); +$attribute->nodeValue = '2'; +var_dump($doc->documentElement->setAttributeNodeNS($attribute)?->nodeValue); +echo $doc->saveXML(), "\n"; +$attribute = $doc->createAttributeNS('http://php.net/ns1', 'hello'); +$attribute->nodeValue = '3'; +var_dump($doc->documentElement->setAttributeNodeNS($attribute)?->nodeValue); +echo $doc->saveXML(), "\n"; +?> +--EXPECT-- +NULL + + + +string(1) "1" + + + +string(1) "2" + +