From: lta at lfdj dot com Operating system: solaris PHP version: 5.1.2 PHP Bug Type: SPL related Bug description: __clone() bug when it's define in class extending arrayObject SPL class
Description: ------------ When a __clone() function is defined for a class that extends arrayObject from SPL, there is no way to clone the objects contained in arrayObject. If you do same code for class not extending the SPL arrayObject but any other objectContainer, there is no problem. Reproduce code: --------------- class bidon { public $foo = "bidon 1"; } class test extends ArrayObject { public $pub = 1; public function __clone() { $this->pub = "cloned"; foreach ($this as $k=>$item) { $this[$k]= clone $item; $this[$k]->foo++; } } } if($original === $cloned2) { echo "bad master clone# $original $cloned2<br>"; } else { echo "good master clone<br>";} foreach ($original as $k=>$obj) { if($original[$k] === $cloned2[$k]) { echo "bad clone childs# $original[$k] $cloned2[$k]<br>"; } else { echo "good child clone<br>";} } Expected result: ---------------- good master clone good child clone good child clone Actual result: -------------- good master clone bad clone childs# Object id #7 Object id #7 bad clone childs# Object id #2 Object id #2 -- Edit bug report at http://bugs.php.net/?id=36885&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36885&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36885&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36885&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=36885&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=36885&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=36885&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=36885&r=needscript Try newer version: http://bugs.php.net/fix.php?id=36885&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=36885&r=support Expected behavior: http://bugs.php.net/fix.php?id=36885&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=36885&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=36885&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=36885&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36885&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=36885&r=dst IIS Stability: http://bugs.php.net/fix.php?id=36885&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=36885&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=36885&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=36885&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=36885&r=mysqlcfg