Commit cf65d03d60e for php.net
commit cf65d03d60e740da6a3b8b6f4f627ecfbce596d6
Merge: 3f9d0bc8ea3 8b13fcc13ed
Author: Ilia Alshanetsky <ilia@ilia.ws>
Date: Tue Sep 8 06:25:33 2026 -0400
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
simplexml: fix addChild() namespace filter on the returned element
diff --cc NEWS
index 56204f6ecc6,31cb928f0bd..4fe4571c513
--- a/NEWS
+++ b/NEWS
@@@ -117,12 -133,19 +117,15 @@@ PH
- SimpleXML:
. Fixed writing to a dimension of the object returned by attributes() not
creating the attribute. (Ilia Alshanetsky)
+ . Fixed child elements of the element returned by
+ SimpleXMLElement::addChild() not being accessible by property name when
+ namespaces are involved. (Ilia Alshanetsky)
- Zip:
+ . Fixed bug GH-17787 (ZipArchive stream stops reading early when the archive
+ is freed while the stream is still open). (Eyüp Can Akman)
. Fixed bug GH-23276 (ZipArchive subclass storing its own stream cannot be
garbage collected). (Weilin Du, ndossche)
- . Fixed ZipArchive::extractTo() and ZipArchive::getFrom*() reporting success
- on corrupted entries. (David Carlier)
- . Fixed ZipArchive::getNameIndex() truncating the entry index to int.
- (David Carlier)
- . Fixed fstat() on a zip:// stream reporting success when the archive cannot
- be opened. (David Carlier)
- SAPI:
. Fixed fuzzer targets failing to build in isolation. (Mrmaxmeier)
diff --cc ext/simplexml/simplexml.c
index 06c627963c8,9e5f293fe78..42944d25844
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@@ -1678,7 -1679,7 +1678,8 @@@ PHP_METHOD(SimpleXMLElement, addChild
xmlNodePtr node, newnode;
xmlNsPtr nsptr = NULL;
xmlChar *localname, *prefix = NULL;
+ bool free_localname = false;
+ const xmlChar *retprefix = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!s!",
&qname, &qname_len, &value, &value_len, &nsuri, &nsuri_len) == FAILURE) {
@@@ -1729,11 -1728,13 +1730,15 @@@
}
}
- node_as_zval_str(sxe, newnode, return_value, SXE_ITER_NONE, localname, prefix, 0);
+ if ((prefix != NULL || nsuri != NULL) && newnode->ns != NULL) {
+ retprefix = newnode->ns->prefix;
+ }
+
+ node_as_zval_str(sxe, newnode, return_value, SXE_ITER_NONE, localname, retprefix, 1);
- xmlFree(localname);
+ if (free_localname) {
+ xmlFree(localname);
+ }
if (prefix != NULL) {
xmlFree(prefix);
}