2

If I send remote data from Zend_Amf to Flex, if two array properties on the object have the same data values they are deserialized at the remote end with the same memory storage.

Example: AS3 object:

Snippet:

[RemoteClass(alias="TestVO")]
public class TestVO
{
  public var test1:Array;
  public var test2:Array;
}

When this receives remote data from Zend_Amf server, if the array data are identical it allocates the same storage to the two arrays.

Eg: From remote (ZendAMF) object I send:

$this->test1 = array("foo", "bar");
$this->test2 = array("foo", "bar");

When I debug the TestVO object in Flex debugger I get:

test1 Array(@597d779)
test2 Array(@597d779)

ie: they reference the same array object.

If I send from the remote server slightly different values for the 2 arrays:

$this->test1 = array("foo", "bar");
$this->test2 = array("bar", "foo");

In the Flex debugger the TestVO object now has two seperate arrays as you'd expect:

test1 Array(@54cb7e9)
test2 Array(@54cb741)

AMF output looks Ok, it always sends two seperate values for test1/test2 even if they have the same values, so I'm guessing it's the way Flex de-serializes this?

Any ideas? Thanks.

Amarghosh
  • 58,710
  • 11
  • 92
  • 121
NigelF
  • 21
  • 2
  • How about two arrays with same numbers in same order instead of strings? Strings are immutable, numbers aren't - meaning all string variables holding "foo" points to the same string object. But two number variables holding 3 points to different memory locations. – Amarghosh Nov 11 '09 at 12:25
  • Yes - arrays with numbers in suffer the same problem. As James mentions below, it seems the "compression" AMF3 uses is being de-serialized incorrectly. Just because the data is the same, it assumes the two references must have originally related to the same variable on the remote end, which is not the case. – NigelF Nov 12 '09 at 10:54

2 Answers2

2

AMF does this to gain some compression over the wire. If you don't want this then you can switch to the AMF0 format instead of AMF3. But I'm not sure how to do that with ZendAMF.

James Ward
  • 29,283
  • 9
  • 49
  • 85
  • Thanks for the explanation. Looks like a bug on the Flash/Flex side - shouldn't the client create seperate data values on de-compression? – NigelF Nov 11 '09 at 14:13
0

Found bug ZF-7634 on Zend Framework implementation of AMF. It is serializing the arrays incorrectly.

http://framework.zend.com/issues/browse/ZF-7634

NigelF
  • 21
  • 2