Issues

ZF-9127: Zend_Form_Element :: _loadValidator() behaviour is changed in 1.10.0 (not backward compatible)

Description

The behaviour of _loadValidator() is changed. In previous realeases the validator was instantiated, if it had a constructor - through a ReflectionClass with newInstanceArgs() and with (array) $validator['options'] as the parameter. In 1.10.0 the parameter is passed as $validator['options'] (no array casting) to newInstance() function, if all the options have keys (which is always the case, when loading the form from a config file).

Example stack trace:

file: /library/Bb/Validate/MatchField.php line: 25 function: errorHandler args: int(2), string(60) "Missing argument 2 for Bb_Validate_MatchField::__construct()", string(35) "/library/Bb/Validate/MatchField.php", int(25), array(1) {array(2) {string(5) "email", string(3) "t_3"}}


function: __construct args: array(2) {string(5) "email", string(3) "t_3"}


file: /library/Zend/Form/Element.php line: 2101 function: newInstance args: array(2) {string(5) "email", string(3) "t_3"}


file: /library/Zend/Form/Element.php line: 1246 function: _loadValidator args: array(3) {string(10) "MatchField", bool(false), array(2) {string(5) "email", string(3) "t_3"}}


file: /library/Zend/Form/Element.php line: 1319 function: getValidators args: -


(...)

Comments

The behaviour of constructing Validators was indeed changed in 1.10.

See [ZF-7153] There is now only one argument, an array, passed to the _construct method.

Not an Issue.

But why this is not described in the migration notes? Upgrading to 1.10.x broke my applications.

Marking as 'not an issue' and 'resolved'. Unfortunately the change did cause an intentional BC break. See ZF-7153 for why this was necessary.