From: ben at last dot fm
Operating system: Linux
PHP version: 5.2.9
PHP Bug Type: Arrays related
Bug description: Referencing an object property causes behaviour change after
clone
Description:
------------
If you create a reference to a property of an object, then clone
the object, the reference will become bi-directional and the property
will no longer behave like a property.
This does not happen if you create, then destroy, the reference BEFORE
cloning.
This persists even if you unset the reference AFTER cloning.
Reproduce code:
---------------
<?php
class A { var $list; }
$a = new A;
$a->list = array( 1, 1, 1, 1, 1 );
$b = clone $a;
$link =& $a->list;
unset($link);
$c = clone $a;
$link =& $a->list;
$d = clone $a;
unset($link);
$e = clone $a;
$b->list = array(2,2,2,2,2);
$c->list = array(3,3,3,3,3);
$d->list = array(4,4,4,4,4);
$e->list = array(5,5,5,5,5);
echo "$a\n$b\n$c\n$d\n$e\n";
Expected result:
----------------
{1}
{2}
{3}
{4}
{5}
Actual result:
--------------
{5}
{2}
{3}
{5}
{5}
--
Edit bug report at http://bugs.php.net/?id=48460&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=48460&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=48460&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=48460&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=48460&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=48460&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=48460&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=48460&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=48460&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=48460&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=48460&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=48460&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=48460&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=48460&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=48460&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48460&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48460&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=48460&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=48460&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=48460&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=48460&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=48460&r=mysqlcfg