From: Alexander Ebert Date: Sun, 25 Sep 2016 22:33:59 +0000 (+0200) Subject: Properly handling destructed nodes X-Git-Tag: 3.0.0_Beta_2~137 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=cfbc13442befc432291bf905ea4e2a75ffca6b7d;p=GitHub%2FWoltLab%2FWCF.git Properly handling destructed nodes --- diff --git a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacode.class.php b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacode.class.php index 4c67812b78..f19b72fdc9 100644 --- a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacode.class.php +++ b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacode.class.php @@ -66,7 +66,7 @@ class HtmlInputNodeWoltlabMetacode extends AbstractHtmlInputNode { /** @var \DOMElement $element */ foreach ($elements as $element) { - if ($element->parentNode === null) { + if (DOMUtil::isRemoved($element) || $element->parentNode === null) { // ignore elements that existed, but have been removed // from the DOM due to action taken by a converter continue; diff --git a/wcfsetup/install/files/lib/util/DOMUtil.class.php b/wcfsetup/install/files/lib/util/DOMUtil.class.php index 6422c05dc5..17d434a27f 100644 --- a/wcfsetup/install/files/lib/util/DOMUtil.class.php +++ b/wcfsetup/install/files/lib/util/DOMUtil.class.php @@ -310,6 +310,18 @@ final class DOMUtil { return false; } + /** + * Nodes can get partially destroyed in which they're still an + * actual DOM node (such as \DOMElement) but almost their entire + * body is gone, including the `nodeType` attribute. + * + * @param \DOMNode $node node + * @return boolean true if node has been destroyed + */ + public static function isRemoved(\DOMNode $node) { + return !isset($node->nodeType); + } + /** * Returns true if provided element is a void element. Void elements are elements * that neither contain content nor have a closing tag, such as `
`.