[php-src] Issue #11288: `Error: Couldn't fetch DOMElement` introduced in 8.2.6, 8.1.19
| From: | fluffycondor | Date: | Mon, 22 May 2023 05:54:54 +0000 |
| Subject: | [php-src] Issue #11288: `Error: Couldn't fetch DOMElement` introduced in 8.2.6, 8.1.19 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244499@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11288
Author: fluffycondor
### Description
Live reproduce: https://3v4l.org/iPl83
The following code:
```php
<?php
$html = <<<HTML
<!DOCTYPE HTML>
<html>
<span class="unwrap_me"><i><span
class="foo">Lorem</span></i><span
class="foo">ipsum</span></span>
</html>
HTML;
$dom = new DOMDocument();
$dom->loadHTML($html);
$spans = iterator_to_array($dom->getElementsByTagName('span')->getIterator());
foreach ($spans as $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 throws
Error: 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