From: saschagros at bluewin dot ch
Operating system: Windows/Linux
PHP version: 5.2.0
PHP Bug Type: SimpleXML related
Bug description: cloning fails on nested SimpleXML-Object
Description:
------------
"clone $simpleXML->subElement1->subElement2" does not work as excepted.
It does not return a clone of itself but a clone of it's parent.
Tested on:
Windows with PHP 5.2.0
Linux with PHP 5.2.0
Linux with PHP 5.0.4
Reproduce code:
---------------
$xml = '<?xml version="1.0" ?>
<test>
<level1>
<level2a>text1</level2a>
<level2b>text2</level2b>
</level1>
</test>';
$test = simplexml_load_string($xml);
print_r($test->level1->level2a);
$test2 = clone $test;
print_r($test2->level1->level2a);
$test3 = clone $test->level1->level2a;
print_r($test3);
Expected result:
----------------
SimpleXMLElement Object
(
[0] => text1
)
SimpleXMLElement Object
(
[0] => text1
)
SimpleXMLElement Object
(
[0] => text1
)
Actual result:
--------------
SimpleXMLElement Object
(
[0] => text1
)
SimpleXMLElement Object
(
[0] => text1
)
SimpleXMLElement Object
(
[level2a] => text1
[level2b] => text2
)
--
Edit bug report at http://bugs.php.net/?id=39760&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=39760&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=39760&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=39760&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39760&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=39760&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39760&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39760&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39760&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39760&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39760&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=39760&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=39760&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39760&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39760&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39760&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39760&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39760&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39760&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39760&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39760&r=mysqlcfg