From: Alexander Ebert Date: Mon, 18 Jul 2022 10:20:11 +0000 (+0200) Subject: Replace use of a PHP 8+ feature X-Git-Tag: 5.5.3_dev_2~10 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c70a77e262ed65c0d92cc3ecb0e1cb1967d5b74d;p=GitHub%2FWoltLab%2FWCF.git Replace use of a PHP 8+ feature `DOMElement::$childElementCount` is supported in PHP 8.0+ only, for PHP 7 we need to manually check for child elements. See https://www.woltlab.com/community/thread/296485-zitat-von-user-nochmal-zitieren/ --- diff --git a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php index 9385bea52d..c672bebdbd 100644 --- a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php +++ b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php @@ -319,7 +319,18 @@ class HtmlInputNodeProcessor extends AbstractHtmlNodeProcessor if ($depth === 0 && $isFullQuote && \count($quotes) > 0) { /** @var \DOMElement $body */ $body = $this->getDocument()->getElementsByTagName('body')[0]; - if ($body->childElementCount === 0) { + + // TODO: This can be simplified in PHP 8.0+ by checking against `$body->childElementCount`. + $hasChildren = false; + /** @var \DOMNode $node */ + foreach ($body->childNodes as $node) { + if ($node->nodeType === \XML_ELEMENT_NODE) { + $hasChildren = true; + break; + } + } + + if (!$hasChildren) { $p = $body->ownerDocument->createElement('p'); $p->textContent = "[\u{2026}]"; $body->appendChild($p);