[php-src] PR #25552: Fix Dom\import_simplexml() returning a legacy object
| From: | lacatoire | Date: | Wed, 18 Nov 2026 13:15:00 +0000 |
| Subject: | [php-src] PR #25552: Fix Dom\import_simplexml() returning a legacy object | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-40770@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25552
Author: lacatoire
Dom\import_simplexml() declares Attr|Element but returns a legacy
DOMElement or DOMAttr when the node already carries one and the document
is not locked to a model yet. Throw the same TypeError as for an already locked
document.
To reproduce:
```php
$doc = new DOMDocument;
$doc->loadXML('<r z="3"><a/></r>');
$element = $doc->documentElement;
$sxe = simplexml_import_dom($element);
var_dump(get_class(Dom\import_simplexml($sxe)));
```
Before (8.4.26, 8.5.12): string(10) "DOMElement".
After: TypeError: Dom\import_simplexml(): Argument #1 ($node) must not be already imported as
a DOMNode
This is a behavior change, so it targets master and has an UPGRADING entry.