|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2021-11-19 16:51 UTC] jules dot bernable at gmail dot com
Description:
------------
When calling `DOMChildNode::replaceWith()` on a given node,
If the node is also part of the argument list, PHP either throws a DOMException or just hangs indefinitely.
The bug is present at least in versions 8.0.12 and 8.1.0RC6
Test script:
---------------
// example 1
$doc = new DOMDocument();
$doc->appendChild($target = $doc->createElement('test'));
$target->replaceWith($target); // PHP Fatal error: Uncaught DOMException: Not Found Error
// example 2
$doc = new DOMDocument();
$doc->appendChild($target = $doc->createElement('test'));
$target->replaceWith($target, 'foo'); // program hangs indefinitely
Expected result:
----------------
Both examples should be handled correctly, like browsers do.
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 18:00:02 2025 UTC |
If you are trying to replace more than one node at once, you have to be careful about iterating over the DOMNodeList. If the old node has a different name from the new node, it will be removed from the list once it has been replaced. Use a regressive loop: $newelement = $xml>createTextNode('Some new node!'); <https://www.novitasphere.us/>github.com