`\DOMElement::$parentElement` requires PHP 8.3+
authorAlexander Ebert <ebert@woltlab.com>
Mon, 29 Jan 2024 22:49:08 +0000 (23:49 +0100)
committerOlaf Braun <info@braun-development.de>
Thu, 7 Mar 2024 15:36:53 +0000 (16:36 +0100)
See https://www.woltlab.com/community/thread/304491-undefined-property-domelement-parentelement/

wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php
wcfsetup/install/files/lib/system/html/node/HtmlNodePlainLink.class.php

index 4a54c269433179fdca1417c99f7a5087b5b86b7e..a26b7ab98c8cdfc52b3920d73c838eff5253640d 100644 (file)
@@ -798,8 +798,9 @@ class HtmlInputNodeProcessor extends AbstractHtmlNodeProcessor
                 }
             } elseif ($parent->nodeName === 'p') {
                 $parentLinkElement = $link;
-                while ($parentLinkElement->parentElement !== $parent) {
-                    $parentLinkElement = $parentLinkElement->parentElement;
+                while ($parentLinkElement->parentNode !== $parent) {
+                    $parentLinkElement = $parentLinkElement->parentNode;
+                    \assert($parentLinkElement instanceof \DOMElement);
                     if ($this->mayContainOtherContent($parentLinkElement, $linebreaks)) {
                         $mayContainOtherContent = true;
                         break;
index 726c0dc6753d66f10cba3cc8ea9b1b05aba1fb57..33083765d4b3f0ce97b0e695d10d54e77858cdb9 100644 (file)
@@ -188,7 +188,7 @@ class HtmlNodePlainLink
 
                 // When multiple links are in the same paragraph, `topLevelParent`
                 // may no longer be a valid reference.
-                if ($this->topLevelParent->parentElement === null) {
+                if ($this->topLevelParent->parentNode === null) {
                     $this->topLevelParent = $this->link;
                     while ($this->topLevelParent->parentNode->nodeName !== 'body') {
                         $this->topLevelParent = $this->topLevelParent->parentNode;
@@ -197,7 +197,7 @@ class HtmlNodePlainLink
 
                 // Link inside other elements(u, i, b, …)
                 while ($next === null && $previous === null && $parent !== $this->topLevelParent) {
-                    $parent = $parent->parentElement;
+                    $parent = $parent->parentNode;
                     $next = $this->findBr($parent, 'nextSibling');
                     $previous = $this->findBr($parent, 'previousSibling');
                 }
@@ -212,16 +212,20 @@ class HtmlNodePlainLink
                 }
 
                 if ($next !== null) {
+                    $ancestor = $this->topLevelParent->parentNode;
+                    \assert($ancestor instanceof \DOMElement);
                     $replaceNode = DOMUtil::splitParentsUntil(
                         $parent,
-                        $this->topLevelParent->parentElement,
+                        $ancestor,
                         false
                     );
                 }
                 if ($previous !== null) {
+                    $ancestor = $this->topLevelParent->parentNode;
+                    \assert($ancestor instanceof \DOMElement);
                     $replaceNode = DOMUtil::splitParentsUntil(
                         $parent,
-                        $this->topLevelParent->parentElement
+                        $ancestor
                     );
                 }
                 \assert($replaceNode instanceof \DOMElement);