|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63575 Cloning are incorrect
Submitted: 2012-11-21 17:52 UTC Modified: 2020-04-23 14:29 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: vadimx at gmail dot com Assigned: cmb (profile)
Status: Closed Package: SimpleXML related
PHP Version: 5.3.18 OS: Windows/Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: vadimx at gmail dot com
New email:
PHP Version: OS:


 [2012-11-21 17:52 UTC] vadimx at gmail dot com
When changing child's in cloned object, it's change in parent object, not in 

Test script:
$xml = '<a><b></b></a>';

$o1 = new SimpleXMlElement($xml);
$o2 = clone $o1;

$r = current($o2->xpath('/a'));
$r->addChild('c',new SimpleXMlElement('<c></c>'));

echo $o1->asXML();
echo PHP_EOL;
echo $o2->asXML();

Expected result:
<?xml version="1.0"?>


Actual result:
<?xml version="1.0"?>



Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-24 15:55 UTC]
-Assigned To: +Assigned To: helly
 [2012-11-24 15:55 UTC]
helly, do you have time to look at this?
 [2017-10-24 07:02 UTC]
-Status: Assigned +Status: Open -Assigned To: helly +Assigned To:
 [2020-04-23 14:28 UTC]
The following pull request has been associated:

Patch Name: Fix #63575: Root elements are not properly cloned
On GitHub:
 [2020-04-23 14:29 UTC]
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2020-06-17 14:49 UTC]
Automatic comment on behalf of
Log: Fix #63575: Root elements are not properly cloned
 [2020-06-17 14:49 UTC]
-Status: Verified +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jul 12 21:01:30 2024 UTC