Bug #63575 [Opn->Ver]: Cloning are incorrect

From: Date: Thu, 23 Apr 2020 14:29:08 +0000
Subject: Bug #63575 [Opn->Ver]: Cloning are incorrect
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226743@lists.php.net to get a copy of this message
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: Open +Status: Verified Type: Bug Package: SimpleXML related Operating System: Windows/Linux PHP Version: 5.3.18 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N 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

« previous php.bugs (#226743) next »