- Notifications
You must be signed in to change notification settings - Fork8k
Description
Description
Live reproduce:https://3v4l.org/iPl83
The following code:
<?php$html =<<<HTML<!DOCTYPE HTML><html><span><i><span>Lorem</span></i><span>ipsum</span></span></html>HTML;$dom =newDOMDocument();$dom->loadHTML($html);$spans =iterator_to_array($dom->getElementsByTagName('span')->getIterator());foreach ($spansas$span) {if ('unwrap_me' ===$span->getAttribute('class')) {$fragment =$dom->createDocumentFragment();$fragment->append(...$span->childNodes);$span->parentNode?->replaceChild($fragment,$span); }}
worked successfully as for 8.2.5, 8.1.18 and earlier.
But as for 8.2.6 and 8.1.19 it throwsError: Couldn't fetch DOMElement
because one of DOMElement's state is corrupted:
object(DOMElement)#142 (1) { ["schemaTypeInfo"]=> NULL}DOMElement Object( [schemaTypeInfo] =>)
PHP Version
PHP 8.2.6, 8.1.19
Operating System
FreeBSD 12.4, Windows 10 x64