Issues

ZF-6939: Callback validation in Zend_Form_Decorator_Callback::setCallback() doesn't allow lambdas.

Issue Type: Bug Created: 2009-06-06T01:20:40.000+0000 Last Updated: 2009-06-06T07:48:12.000+0000 Status: Resolved Fix version(s): Reporter: Mon Zafra (monzee) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Form

Related issues: Attachments:

Description

The callback validation in the callback decorator is too restrictive and arguably wrong.

<pre class="highlight">
    public function setCallback($callback)
    {
        if (!is_string($callback) && !is_array($callback)) {
            require_once 'Zend/Form/Exception.php';
            throw new Zend_Form_Exception('Invalid callback provided to callback decorator');
        }

        if (is_array($callback)) {
            if (2 !== count($callback)) {
                require_once 'Zend/Form/Exception.php';
                throw new Zend_Form_Exception('Invalid method callback provided to callback decorator');
            }
        }

        $this->_callback = $callback;
        return $this;
    }

That whole check should simply be if (!is_callable($callback)) {throw new Zend_Form_Exception();}. As it is right now, it won't accept the return values of create_function or PHP 5.3-style lambdas.

Comments

Posted by Matthew Weier O'Phinney (matthew) on 2009-06-06T07:48:03.000+0000

Thanks --- you're absolutely correct.

Code updated in trunk and 1.8 release branch.

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