Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.0.1
-
Fix Version/s: 1.6.0
-
Component/s: Zend_Db_Table
-
Labels:None
-
Fix Version Priority:Should Have
Description
Bill, I am noticing circular references when I try to return an array:
Ponder this:
$thing = new ArrayObject($row->toArray(), ArrayObject::ARRAY_AS_PROPS);
$thing->foo= 'bar';
Also adds foo = bar into the _data of the $row.
Perhaps toArray() shoudl cast _data to (Array) before returning it?
-ralph
Yes, ArrayObject's constructor make a reference on the variable passed to it.
Casting to array before returning, explicitly tells PHP to make a real copy (not a COW) of the returned array.
See the first comment at http://www.php.net/manual/en/function.ArrayObject-construct.php
I don't know if this sould be considered as a ZF issue, or a PHP issue, it's actually confused, as you can read in that bug report : http://bugs.php.net/bug.php?id=42065