[php-src] master: Merge branch 'PHP-8.6'
| From: | Ilia Alshanetsky | Date: | Tue, 29 Sep 2026 18:55:23 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.6' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141721@lists.php.net to get a copy of this message | ||
Author: Ilia Alshanetsky (iliaal)
Date: 2026-09-29T14:53:14-04:00
Commit: https://github.com/php/php-src/commit/efb0111d926cc8a9fb3568385b712f1e324ec697
Raw diff: https://github.com/php/php-src/commit/efb0111d926cc8a9fb3568385b712f1e324ec697.diff
Merge branch 'PHP-8.6'
* PHP-8.6:
ext/libxml: Keep SimpleXML children alive across reconstruction
Changed paths:
A ext/simplexml/tests/reconstruct_with_retained_child.phpt
M ext/libxml/libxml.c
Diff:
diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c
index 361339a3466f..e53746379428 100644
--- a/ext/libxml/libxml.c
+++ b/ext/libxml/libxml.c
@@ -1466,6 +1466,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>"