Fix `XML::write()` for comments in root element
authorMatthias Schmidt <gravatronics@live.com>
Mon, 15 Oct 2018 17:13:37 +0000 (19:13 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 15 Oct 2018 17:13:37 +0000 (19:13 +0200)
See #2545

wcfsetup/install/files/lib/util/XML.class.php

index d22b19941fc969e578953057f500e531a16cbe2a..ddaf98001fe9fcf5972ac53f44ada586b121b84e 100644 (file)
@@ -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);
        }