From 9dde97d77889671d5073ad0b27647cfd60db1976 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Mon, 15 Oct 2018 19:13:37 +0200 Subject: [PATCH] Fix `XML::write()` for comments in root element See #2545 --- wcfsetup/install/files/lib/util/XML.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/util/XML.class.php b/wcfsetup/install/files/lib/util/XML.class.php index d22b19941f..ddaf98001f 100644 --- a/wcfsetup/install/files/lib/util/XML.class.php +++ b/wcfsetup/install/files/lib/util/XML.class.php @@ -224,7 +224,10 @@ class XML { $this->getAttributes($this->document->documentElement) ); foreach ($this->document->documentElement->childNodes as $childNode) { - $this->writeElement($writer, $childNode, $cdata); + // only consider dom elements, ignore comments + if ($childNode instanceof \DOMElement) { + $this->writeElement($writer, $childNode, $cdata); + } } $writer->endDocument($fileLocation); } -- 2.20.1