Commit 33d243c2142 for php.net
commit 33d243c214253c3aa18618902fa86273d6938784
Author: David Carlier <devnexen@gmail.com>
Date: Sun Jul 5 21:06:28 2026 +0100
ext/dom: fix GH-22570 new test
diff --git a/ext/dom/tests/modern/xml/gh22570.phpt b/ext/dom/tests/modern/xml/gh22570.phpt
index af78acf00df..3d648aac5e4 100644
--- a/ext/dom/tests/modern/xml/gh22570.phpt
+++ b/ext/dom/tests/modern/xml/gh22570.phpt
@@ -15,13 +15,15 @@
zend.max_allowed_stack_size=512K
--FILE--
<?php
-// Build via the DOM API, not the parser: libxml caps parse depth even with
-// LIBXML_PARSEHUGE on some platforms; the serializer recursion is the bug.
+// Build bottom-up so the insertion cycle-check stays O(1); top-down is O(n^2).
$doc = Dom\XMLDocument::createEmpty();
-$node = $doc->appendChild($doc->createElement('root'));
+$node = $doc->createElement('a');
for ($i = 0; $i < 100000; $i++) {
- $node = $node->appendChild($doc->createElement('a'));
+ $parent = $doc->createElement('a');
+ $parent->appendChild($node);
+ $node = $parent;
}
+$doc->appendChild($node);
try {
$doc->saveXml();