Use `XPath::query()` for its superior performance
authorAlexander Ebert <ebert@woltlab.com>
Mon, 12 Apr 2021 20:14:20 +0000 (22:14 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 12 Apr 2021 20:14:20 +0000 (22:14 +0200)
wcfsetup/install/files/lib/system/html/node/AbstractHtmlNodeProcessor.class.php
wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeProcessor.class.php

index 6e4cf7222996dc5ad426b88eb195c1daac750032..e07b677798f1d497d280807f3a7dc737123fc2de 100644 (file)
@@ -283,7 +283,7 @@ abstract class AbstractHtmlNodeProcessor implements IHtmlNodeProcessor {
                }
                
                $elements = [];
-               foreach ($this->getDocument()->getElementsByTagName($tagName) as $element) {
+               foreach ($this->getXPath()->query("//{$tagName}") as $element) {
                        $elements[] = $element;
                }
                
index d2e54f1740404b02f46139eae164b6d614bf39e4..9ac423ce5195d85a67e47f78b4185bfd5fb6d641 100644 (file)
@@ -98,7 +98,6 @@ class HtmlOutputNodeProcessor extends AbstractHtmlNodeProcessor {
                
                if ($this->outputType !== 'text/html') {
                        // convert `<p>...</p>` into `...<br><br>`
-                       $paragraphs = [];
                        foreach ($this->getXPath()->query('//p') as $paragraph) {
                                $isLastNode = true;
                                $sibling = $paragraph;