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: https://github.com/php/php-src/issues/16967

Fixes #5341
This commit is contained in:
Dan Brown 2024-11-28 16:30:59 +00:00
parent 68ce340741
commit 415cd6a360
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
2 changed files with 11 additions and 2 deletions

View File

@ -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);
}

View File

@ -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.
*/