Skip to content

Commit 415cd6a

Browse files
committed
Includes: Workaround for PHP 8.3.14 bug
Changed DOMText creation to be done via document so its document reference is correct to avoid a bug in PHP 8.3.14. Ref: php/php-src#16967 Fixes #5341
1 parent 68ce340 commit 415cd6a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

app/Entities/Tools/PageIncludeParser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ protected function splitTextNodesAtTags(DOMNode $textNode): array
104104

105105
if ($currentOffset < $tagStartOffset) {
106106
$previousText = substr($text, $currentOffset, $tagStartOffset - $currentOffset);
107-
$textNode->parentNode->insertBefore(new DOMText($previousText), $textNode);
107+
$textNode->parentNode->insertBefore($this->doc->createTextNode($previousText), $textNode);
108108
}
109109

110-
$node = $textNode->parentNode->insertBefore(new DOMText($tagOuterContent), $textNode);
110+
$node = $textNode->parentNode->insertBefore($this->doc->createTextNode($tagOuterContent), $textNode);
111111
$includeTags[] = new PageIncludeTag($tagInnerContent, $node);
112112
$currentOffset = $tagStartOffset + strlen($tagOuterContent);
113113
}

app/Util/HtmlDocument.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use DOMElement;
77
use DOMNode;
88
use DOMNodeList;
9+
use DOMText;
910
use DOMXPath;
1011

1112
/**
@@ -81,6 +82,14 @@ public function createElement(string $localName, string $value = ''): DOMElement
8182
return $element;
8283
}
8384

85+
/**
86+
* Create a new text node within this document.
87+
*/
88+
public function createTextNode(string $text): DOMText
89+
{
90+
return $this->document->createTextNode($text);
91+
}
92+
8493
/**
8594
* Get an element within the document of the given ID.
8695
*/

0 commit comments

Comments
 (0)