ZF-5755: Class mapping with autoloader

Description

Dispatching Remote Object calls from Flex to PHP, object parameters are not mapped correctly and an exception is thrown "exception 'Zend_Amf_Exception' with message 'Unable to parse null body data My_Mapped_Vo mapped class is not defined' in ...".

class My_Mapped_Vo {} locates in models/My/Mapped/Vo.php where models-directory is set in include path and ZF autoloader is registered. The problem can be rounded using explicit class mapping setClassMap("My_Mapped_Vo", "My_Mapped_Vo") but this is needed only when passing objects as parameters to service calls. Service calls are mapped correctly without explicitly using setClassMap().

Comments

Hi, I currently solve this problem modifing Zend/Amf/Parse/TypeLoader.php (1.7.7) on line 105 replacing "return false;" by "return $className;". I'm not sure if this patch is right, but I'll be trying it for a while. Probably, this will cause unexpected behavior.

In my AS3 class, I put "[RemoteClass(alias="My_Mapped_Vo")]" and it works fine without setClassMap.

What do you think?

JMT

I can confirm that Juan's simple fix solves the same issue for me.

I can also confirm that JMT's solution fixes the problem. (In version 1.7.4, the correct line would be 95 :))

The TypeLoader.php hasn't had any changes from 1.7.7 to 1.8.0, so I suggest patching the file with JMT's solution.

The SVN revision 15454 is also broken and the same fix addresses the problem.

Although it is not changed the way you have suggested the changes in the incubator should resolve this issue both ways. By default all class mapping to and from php defaults to the class name. Please check out zend_amf_server and Zend_amf_parse_typeloader from the incubator and let me know if it does not resolve your feature request. I'll add your suggestion if it does not do the trick!

Replacing the Zend/Amf-directory with the incubator's version, I got the following error:

HTTP/1.1 200 OK Date: Tue, 12 May 2009 07:03:57 GMT Server: Apache/2.0.59 (Unix) PHP/5.2.6 DAV/2 X-Powered-By: PHP/5.2.6 Content-Length: 599 Content-Type: text/html


Warning: require_once(Zend/Amf/Value/MessageBody.php) [function.require-once]: failed to open stream: No such file or directory in /Users/tero/Zend/Svn/incubator/Zend/Amf/Server.php on line 31

Fatal error: require_once() [function.require]: Failed opening required 'Zend/Amf/Value/MessageBody.php' (include_path='.:../library:../application/default/models/:.:/Applications/MAMP/bin/php5/lib/php') in /Users/tero/Zend/Svn/incubator/Zend/Amf/Server.php on line 31

I had exactly the same problem, and I can comfirm that JMT's solution fixes it.

Bulk change of all issues last updated before 1st January 2010 as "Won't Fix".

Feel free to re-open and provide a patch if you want to fix this issue.