ZF-6939: Callback validation in Zend_Form_Decorator_Callback::setCallback() doesn't allow lambdas.
Description
The callback validation in the callback decorator is too restrictive and arguably wrong.
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.