From c70a77e262ed65c0d92cc3ecb0e1cb1967d5b74d Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 18 Jul 2022 12:20:11 +0200 Subject: [PATCH] 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/ --- .../input/node/HtmlInputNodeProcessor.class.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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); -- 2.20.1