php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80600 DOMChildNode::remove() doesn't work on CharacterData nodes
Submitted: 2021-01-06 19:55 UTC Modified: 2021-01-07 09:42 UTC
From: jules dot bernable at gmail dot com Assigned: beberlei (profile)
Status: Closed Package: DOM XML related
PHP Version: 8.0.0 OS: debian
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jules dot bernable at gmail dot com
New email:
PHP Version: OS:

 

 [2021-01-06 19:55 UTC] jules dot bernable at gmail dot com
Description:
------------
CharacterData nodes implement the new DomChildNode interface, but the DOMChildNode::remove() method doesn't work.

See the provided test script.
Text, comments and CDATA nodes should be removed. They are not.


Test script:
---------------
<php

$doc = new \DOMDocument();
$doc->loadXML('<a>foo</a>');
$doc->documentElement->firstChild->remove();
echo $doc->saveXML($doc->documentElement);

Expected result:
----------------
<a></a>

Actual result:
--------------
<a>foo</a>

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-01-06 20:02 UTC] nikic@php.net
-Assigned To: +Assigned To: beberlei
 [2021-01-07 09:42 UTC] beberlei@php.net
confirmed, also for other nodes that extend DOMCharacterData. DOMCharacterData::remove does not seem to use dom_child_node_remove helper function that was added at some point, but the code looks the same and correct anyways. Probably a mistake in the assumptions how DOMCharacterData nodes fit into libxml hierarchy. I will look into this over the next days.
 [2021-02-01 22:14 UTC] beberlei@php.net
The following pull request has been associated:

Patch Name: Fix bug #80600 DOMChildNode::remove does not work on DOMCharacterData.
On GitHub:  https://github.com/php/php-src/pull/6660
Patch:      https://github.com/php/php-src/pull/6660.patch
 [2021-02-02 19:31 UTC] beberlei@php.net
Automatic comment on behalf of kontakt@beberlei.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=665e1f324a543bd04bcdd8dec089b82091c61671
Log: Fix bug #80600 DOMChildNode::remove does not work on DOMCharacterData.
 [2021-02-02 19:31 UTC] beberlei@php.net
-Status: Assigned +Status: Closed
 [2021-02-12 16:16 UTC] beberlei@php.net
Automatic comment on behalf of kontakt@beberlei.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=6ec25f386ff058b5ecda6f11c5f62e934b31f660
Log: Fixed bug #80600
 [2021-02-15 09:38 UTC] nikic@php.net
Automatic comment on behalf of kontakt@beberlei.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=6ec25f386ff058b5ecda6f11c5f62e934b31f660
Log: Fixed bug #80600
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 10:01:29 2024 UTC