Bug #63575 [Ver->Csd]: Cloning are incorrect
Edit report at https://bugs.php.net/bug.php?id=63575&edit=1
ID: 63575
Updated by: cmb@php.net
Reported by: vadimx at gmail dot com
Summary: Cloning are incorrect
-Status: Verified
+Status: Closed
Type: Bug
Package: SimpleXML related
Operating System: Windows/Linux
PHP Version: 5.3.18
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3a0bdb720a9e54b91c812665f36b936e6cf44ef3
Log: Fix #63575: Root elements are not properly cloned
Previous Comments:
------------------------------------------------------------------------
[2020-04-23 14:28:51] cmb@php.net
The following pull request has been associated:
Patch Name: Fix #63575: Root elements are not properly cloned
On GitHub: https://github.com/php/php-src/pull/5438
Patch: https://github.com/php/php-src/pull/5438.patch
------------------------------------------------------------------------
[2012-11-24 15:55:57] laruence@php.net
helly, do you have time to look at this?
------------------------------------------------------------------------
[2012-11-21 17:52:57] vadimx at gmail dot com
Description:
------------
When changing child's in cloned object, it's change in parent object, not in
cloned.
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"?>
<a><b/></a>
<a><b/><c></c></a>
Actual result:
--------------
<?xml version="1.0"?>
<a><b/><c></c></a>
<a><b/></a>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63575&edit=1
Thread (6 messages)