[php-src] master: Merge branch 'PHP-8.4' into PHP-8.5
| From: | Ilia Alshanetsky | Date: | Tue, 29 Sep 2026 18:55:17 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.4' into PHP-8.5 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141720@lists.php.net to get a copy of this message | ||
Author: Ilia Alshanetsky (iliaal)
Date: 2026-09-29T14:16:24-04:00
Commit: https://github.com/php/php-src/commit/e926c2a2ec700b40d84465abb8f419697c80a5b0
Raw diff: https://github.com/php/php-src/commit/e926c2a2ec700b40d84465abb8f419697c80a5b0.diff
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
ext/libxml: Keep SimpleXML children alive across reconstruction
Changed paths:
A ext/simplexml/tests/reconstruct_with_retained_child.phpt
M NEWS
M ext/libxml/libxml.c
Diff:
diff --git a/NEWS b/NEWS
index 85b5065108ad..4ffe541ab5d4 100644
--- a/NEWS
+++ b/NEWS
@@ -140,6 +140,10 @@ PHP NEWS
. Fixed exceptions from user-defined create_sid() handlers being replaced
by return-value validation errors. (Ilia Alshanetsky)
+- SimpleXML:
+ . Fixed reconstructing a SimpleXMLElement freeing a child element that
+ another variable still references. (Ilia Alshanetsky)
+
- SQLite:
. Fixed a crash when SQLite3::close() is called from a userland callback.
(Ilia Alshanetsky)
diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c
index 1fe51a2fbe89..dcbdd6bca57f 100644
--- a/ext/libxml/libxml.c
+++ b/ext/libxml/libxml.c
@@ -1470,6 +1470,7 @@ PHP_LIBXML_API void php_libxml_node_decrement_resource(php_libxml_node_object
*o
obj_node->_private = NULL;
}
}
+ object->node = NULL;
}
if (object != NULL && object->document != NULL) {
/* Safe to call as if the resource were freed then doc pointer is NULL */
diff --git a/ext/simplexml/tests/reconstruct_with_retained_child.phpt
b/ext/simplexml/tests/reconstruct_with_retained_child.phpt
new file mode 100644
index 000000000000..c6a1cb418089
--- /dev/null
+++ b/ext/simplexml/tests/reconstruct_with_retained_child.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SimpleXMLElement reconstruction with a retained child
+--EXTENSIONS--
+simplexml
+--FILE--
+<?php
+$xml = simplexml_load_string('<root><child>old</child></root>');
+$child = $xml->child;
+
+$xml->__construct('<root><new>new</new></root>');
+
+var_dump((string) $xml->new);
+var_dump((string) $child);
+var_dump($child->asXML());
+?>
+--EXPECT--
+string(3) "new"
+string(3) "old"
+string(18) "<child>old</child>"