Skip to content

Fix Dom\import_simplexml() returning a legacy object - #25552

Open
lacatoire wants to merge 1 commit into
php:masterfrom
lacatoire:fix/dom-import-simplexml-legacy-wrapper-master
Open

lacatoire wants to merge 1 commit into
php:masterfrom
lacatoire:fix/dom-import-simplexml-legacy-wrapper-master

Conversation

@lacatoire

Copy link
Copy Markdown
Member

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:

$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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant