|
As far as I've seen, the current AMF Serializer doesn't write class traits nor references. So your findings are definitely a missing feature on the Zend_Amf side. I'll also need that feature soon. I would greatly appreciate if you submitted a path. I can write the unit tests. Please use the code from the zend incubator as a lot of zend amf is changing. Greatly appreciate your help with this. Wade This bug keeps Zend Amf from fully implementing the AMF3 protocol. As promised, here is a patch to for the Amf3 Serializer. It is rather huge as support for object references has an impact on nearly everything of the current serializer. (This patch is against revision 15132 in http://framework.zend.com/svn/framework/standard/incubator The following features were added:
There is one notable glitch introduced with this patch: I've tested most of the code, except the ByteArray support. A descent testsuite is still needed. BTW. This patch also addresses the problems discussed in Comments and (failing) tests are greatly appreciated. Cheers Uploaded new version of the patch. I forgot to exlude properties starting with "_" when sending dynamic objects. Thanks for the correction. (as I said a testsuite is still needed Regards Stefan Ok that's what I thought it was... We are using these behaviors, and in my tests your patch seems to work as expected !??. Here is what I do on AS side : package com.vega.core.model.amf { [RemoteClass(alias="com.vega.core.model.amf.InnerObj")] dynamic public class InnerObj { public var a:String; } } package com.vega.core.model.amf { [RemoteClass(alias="com.vega.core.model.amf.Obj")] public class Obj { public var innerObj:InnerObj; } } And on PHP side : class Obj
{
public $_explicitType = "com.vega.core.model.amf.Obj";
// public $innerObj;
}
class InnerObj
{
public $_explicitType = "com.vega.core.model.amf.InnerObj";
public $a = "youhou";
}
function testReferences ()
{
$a = new Obj();
$a->innerObj = new InnerObj();
// try dynamic member
$a->innerObj->b = "test";
$b = new Obj();
$b->innerObj = $a->innerObj;
return array($a,$b);
}
And I get the corrrect result in AS i.e. :
In which cases will this fail ? Hi Mat, I currently don't have the time to check this. I'm on vacation for one week. If that works for you it will most likely fail if you instntiate a second InnerObj, and define a dynamic member c. From this object only the members of the instance which occured first will get transferred. will result in 2 objects, one with b="aa" and the second with b=null and c undefined Regards Stefan I applied this patch and I'd like to test it but I can't seem to trigger the switch between Amf0 and Amf3 - See extensive whinging about this in Stefan Klug can you update your patch against the current standard trunk. I have added a couple patches for other bugs and I can't get your patch to merge without lots of conflicts. I can go line by line if I really need to. Thanks! Hi Wade, please revert the last commit to Zend/Amf/Parse/Amf3/Serializer.php, then my patch should apply cleanly (I didn't try, only had a look at the SVN log). That last commit ( Regards Stefan I reverted to 15896 and the patch still can not be applied. Can you attach your serializer and I can just go line by line. Hi Wade, I updated the patch to work with todays standard trunk (011-Zend_Amf_Parse_Amf3_Serializer.patch) and also attached my complete Serializer.php BTW could you explain the exact semantics of the Incubator? I thought the Incubator is always the bleeding edge and the place for experimentation, whilest the trunk is a mostly stable version and only takes commits for files which don't exist in the incubator or copies from the incubator. But the Amf3 Serializer exists in Incubator, still you are committing to trunk. How are users expected to handle this situation? Thanks a lot for clarification. Regards Stefan Committed to trunk with unit tests updated for shared references. Thanks stefan klug for your diligent work and suppling the As3 serialization patch! This has been resolved in 1.8.4 please let me know if anyone experiences any additional issues. Hello Wade, Here, the next question comes in: when reading complex objects, like dates, the method calls readString - if the date object has a reference inside (I am not whether this is possible at all), the readString method puts the complex object again in the $_stringReferences. Thanks again for this framework, I am using it on a daily basis and like it very much, |
||||||||||||||||||||||||||||||||||||||||||||
Anybody ? This is quite cumbersome... It forces us to have a kind of hashmap referencing all instances to avoid duplicates and so on.