Skip to content

NOW MANAGED ON CODEBERG

Includes: Workaround for PHP 8.3.14 bug

Dan Brown415cd6a360f9
diff --git a/app/Entities/Tools/PageIncludeParser.php b/app/Entities/Tools/PageIncludeParser.php
index dad7c29e6..e0b89f158 100644
--- a/app/Entities/Tools/PageIncludeParser.php
+++ b/app/Entities/Tools/PageIncludeParser.php
@@ -104,10 +104,10 @@ class PageIncludeParser
if ($currentOffset < $tagStartOffset) {
$previousText = substr($text, $currentOffset, $tagStartOffset - $currentOffset);
- $textNode->parentNode->insertBefore(new DOMText($previousText), $textNode);
+ $textNode->parentNode->insertBefore($this->doc->createTextNode($previousText), $textNode);
}
- $node = $textNode->parentNode->insertBefore(new DOMText($tagOuterContent), $textNode);
+ $node = $textNode->parentNode->insertBefore($this->doc->createTextNode($tagOuterContent), $textNode);
$includeTags[] = new PageIncludeTag($tagInnerContent, $node);
$currentOffset = $tagStartOffset + strlen($tagOuterContent);
}
diff --git a/app/Util/HtmlDocument.php b/app/Util/HtmlDocument.php
index b8c53d439..7517955b9 100644
--- a/app/Util/HtmlDocument.php
+++ b/app/Util/HtmlDocument.php
@@ -6,6 +6,7 @@ use DOMDocument;
use DOMElement;
use DOMNode;
use DOMNodeList;
+use DOMText;
use DOMXPath;
/**
@@ -81,6 +82,14 @@ class HtmlDocument
return $element;
}
+ /**
+ * Create a new text node within this document.
+ */
+ public function createTextNode(string $text): DOMText
+ {
+ return $this->document->createTextNode($text);
+ }
+
/**
* Get an element within the document of the given ID.
*/