|
I would second the ArrayObject suggestion. There are similar changes that I need to re-base and commit so that doctrine 2.0 works with zend amf Would this be the reason why arrays that equal the same value in php are removed? Food.php class Foo
{
public function getData()
{
return new array(
array('Test Key 1' => '', 'Test Key 2' = ''),
array('Test Key 1' => 'Hello', 'Test Key 2' = ''),
array('Test Key 1' => 'Hello', 'Test Key 2' = ''),
array('Test Key 1' => 'Hello', 'Test Key 2' = 'World') );
}
}
This returns a blank array for [2] because it matches perfectly with [1]. @Brad My object had a number of array properties, each array had upto 20 integer elements. When two (or more) arrays had the same elements in the same order, they would be deserialised in Flex with the same memory reference. As the data changed, different arrays would reference each other, causing some very weird behaviour on the client! Unlike objects array's in PHP do not have identities. Talking with Stas if we were to cast the array into an arrayobject we would loose all reference anyway. We are just going to remove array references from the serialization process. Expanding on Wade's comment - basically there's no way in PHP to know one array from another (just as two strings saying "a" are the same, so are two arrays array("a")). Since this is not going to change anytime soon, and such behavior apparently leads to confusion (as in AMF/AS arrays are objects and in PHP they are primitive) I think removing array refs would be the best way to proceed. fixed in trunk and 1.10 branch - no more refs for arrays hi, I have a little problem with your solution for this bug. I think their is a link with cyclic reference : when i have cyclic references and array there is a bug. Maybe another solution can be found ? Mikael, could you please have some reproducing code? P.S. looks like there was a bug in the fix, try the trunk now. Yeah, thanks the fix works fine I haven't a "simple" reproducing code sorry ... But the idea is to make a complex object with array/date/etc and manny array and cyclic reference and look at if it is correctly serialized/deserialized. |
||||||||||||||||||||||||||||||||||||||
Phew, that's a nasty problem.
You're right, that this case didn't happen in version 1.8.3, but only because there was no referencing at all. The problem is that even a === comparison of a array compares the values.
So array("foo") === array("foo") would return true even though the arrays should be seperate instances.
Currently I see the following possible solution:
We could disable referencing of arrays at all. This would solve this problem at the expense of no array referencing (lets hope nobody relies on that feature... ).
Additionally we should add support and promote the use of ArrayObjects. Using ArrayObjects would solve the referencing problems, as they can be correctly compared using ===.
Any opinions?
Cheers
Stefan Klug