php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81642 DOMChildNode::replaceWith() bug when replacing a node with itself.
Submitted: 2021-11-19 16:51 UTC Modified: 2022-04-25 12:59 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: jules dot bernable at gmail dot com Assigned: beberlei (profile)
Status: Verified Package: DOM XML related
PHP Version: 8.0.0 OS: debian unstable
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
49 + 15 = ?
Subscribe to this entry?

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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-11-21 11:55 UTC] patrickallaert@php.net
-PHP Version: 8.1.0RC6 +PHP Version: 8.0.0
 [2022-04-25 12:59 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: beberlei
 [2022-04-25 12:59 UTC] cmb@php.net
I can confirm the reported issues.

Benjamin, could you have a look at this?
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu May 26 07:03:36 2022 UTC