Bug #81642 [Com]: DOMChildNode::replaceWith() bug when replacing a node with itself.

From: Date: Sat, 03 Dec 2022 05:39:51 +0000
Subject: Bug #81642 [Com]: DOMChildNode::replaceWith() bug when replacing a node with itself.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243039@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81642&edit=1 ID: 81642 Comment by: maypayne146 at gmail dot com Reported by: jules dot bernable at gmail dot com Summary: DOMChildNode::replaceWith() bug when replacing a node with itself. Status: Verified Type: Bug Package: DOM XML related Operating System: debian unstable PHP Version: 8.0.0 Assigned To: beberlei Block user comment: N Private report: N New Comment: The Element.replaceWith () method replaces this Element in the children list of its parent with a set of Node or string objects. String objects are inserted as equivalent Text nodes. A set of Node or string objects to replace. None ( undefined ). Thrown when the node cannot be inserted at the specified point in the hierarchy. <https://www.fragomen-connect.com/>github.com Previous Comments: ------------------------------------------------------------------------ [2022-11-30 05:15:55] hazerissa1 at gmail dot com the issue is that when we boot a node with --replace_address_first_boot, the node maybe set with itself being a seed - in this case the node currently boots and may set its token on its own instead of taking the old node tokens. <https://www.mylabcorp.me/>github.com ------------------------------------------------------------------------ [2022-09-13 18:14:29] stri73971 at gmail dot com The following pull request has been associated: Patch Name: Fixed and simplified array_replace description On GitHub: https://github.com/php/doc-de/pull/76 Patch: https://github.com/php/doc-de/pull/76.patch ------------------------------------------------------------------------ [2022-06-10 09:22:14] afshin dot meh at gmail dot com I'm happy to look into this as well if it's not being worked on yet? ------------------------------------------------------------------------ [2022-04-25 12:59:59] cmb@php.net I can confirm the reported issues. Benjamin, could you have a look at this? ------------------------------------------------------------------------ [2021-11-19 16:51:53] 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. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=81642&edit=1

« previous php.bugs (#243039) next »