From 0d369d74165054b5801fe4a7fbad17400d48effa Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 12 Apr 2021 19:21:21 +0200 Subject: [PATCH] Avoid updates to DOMNodeList for childNodes --- wcfsetup/install/files/lib/util/DOMUtil.class.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/util/DOMUtil.class.php b/wcfsetup/install/files/lib/util/DOMUtil.class.php index 52c4607727..238d5a1f24 100644 --- a/wcfsetup/install/files/lib/util/DOMUtil.class.php +++ b/wcfsetup/install/files/lib/util/DOMUtil.class.php @@ -483,8 +483,13 @@ final class DOMUtil { throw new \InvalidArgumentException("Preserving child nodes is only supported for DOMElement."); } - while ($node->hasChildNodes()) { - self::insertBefore($node->childNodes->item(0), $node); + $children = []; + foreach ($node->childNodes as $childNode) { + $children[] = $childNode; + } + + foreach ($children as $child) { + self::insertBefore($child, $node); } } -- 2.20.1