|  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: 2017-10-24 07:02 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:
Status: Open 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

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:
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Sep 21 19:01:26 2019 UTC