Repository navigation
Conversation
devnexen
reviewed
Dec 1, 2026
| } | ||
|
|
||
| DOM_GET_OBJ(elemp, id, xmlNodePtr, intern); | ||
|
|
Member
There was a problem hiding this comment.
nit
diff --git a/ext/dom/element.c b/ext/dom/element.c
--- a/ext/dom/element.c
+++ b/ext/dom/element.c
@@ -1417,6 +1417,10 @@ static void dom_element_set_id_attribute_ns(INTERNAL_FUNCTION_PARAMETERS, bool modern)
DOM_GET_OBJ(elemp, id, xmlNodePtr, intern);
+ if (modern && uri_len == 0) {
+ uri = NULL;
+ }
+
attrp = xmlHasNsProp(elemp, BAD_CAST name, BAD_CAST uri);
if (attrp == NULL || attrp->type == XML_ATTRIBUTE_DECL) {
php_dom_throw_error(NOT_FOUND_ERR, dom_get_strict_error(intern->document));
Member
There was a problem hiding this comment.
I trust you ll find a test case for it ;)
Contributor
Author
There was a problem hiding this comment.
Hi @devnexen, thank you for your suggestion. I applied it and added another test assertion for that case. I also updated the PR description for the empty string.
…mespace The method was an implementation alias of DOMElement::setIdAttributeNS(), which parses the namespace as a non-nullable string, although the stub declares ?string. Give it its own entry that accepts null as no namespace and, like the other *NS methods of Dom\Element, treats an empty namespace as no namespace too.
thunderer
force-pushed
the
fix/dom-setidattributens-null
branch
from
December 1, 2026 18:11
fae958f to
060ea2a
Compare
devnexen
approved these changes
Dec 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes GH-25998.
Dom\Element::setIdAttributeNS()now has its own method entry that parses$namespaceas a nullable string, sonullmeans no namespace, as the stub declares. Like the other*NSmethods ofDom\Element, it also treats""as no namespace. Before,nullthrew aTypeErrorin strict mode and was otherwise coerced to""with a deprecation, and""matched only an attribute whose namespace is the empty string, for example a DTD default attribute parsed withLIBXML_DTDATTRor an attribute of an imported legacy node.DOMElement::setIdAttributeNS()is unchanged.