Issues

ZF-5439: Zend_Amf_Server::addFunction() throws exception when passed callback of object instance method

Issue Type: Bug Created: 2009-01-09T10:44:10.000+0000 Last Updated: 2011-08-14T18:59:57.000+0000 Status: Open Fix version(s): Reporter: Darby Felton (darby) Assignee: Wade Arnold (wadearnold) Tags: - Zend_Amf

  • zf-crteam-padraic
  • zf-crteam-priority

Related issues: Attachments:

Description

Zend_Amf_Server of ZF version 1.7.2 throws an exception when the addFunction() method is called with a callback containing an object instance method as in the following:

<pre class="highlight">
$server = new Zend_Amf_Server();
$server->addFunction(array($object, 'somePublicAMFResponderMethod'));

The exception message is simply "Unable to attach function".

It's clear within the addFunction() body why this occurs (for the first array element of $function, $func is an object, not a string or function):

<pre class="highlight">
        $function = (array) $function;
        foreach ($function as $func) {
            if (!is_string($func) || !function_exists($func)) {
                require_once 'Zend/Amf/Server/Exception.php';
                throw new Zend_Amf_Server_Exception('Unable to attach function');
            }
            $this->_methods[] = Zend_Server_Reflection::reflectFunction($func, $argv, $namespace);
        }

Comments

Posted by old of Satoru Yoshida (yoshida@zend.co.jp) on 2009-04-03T23:32:24.000+0000

Hi, Darby.

Do you mean each message should be different one? For example, the parameter is not string nor array, the parameter is not function name... etc

Posted by Darby Felton (darby) on 2009-04-06T05:01:55.000+0000

No, I wasn't meaning that the exception message should be different based on the type of callback sent. The problem to which I refer in the description is that the addFunction() method claims to be able to accept a valid callback, but an essential callback form is not supported by the current code base. If a user supplies a valid callback using an object instance's method (e.g., array($object, 'somePublicMethod')), then Zend_Amf_Server throws an exception, because $object will pass neither the is_string() test nor the function_exists() test in the addFunction() body.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts