Zend Framework

Zend_File_Transfer_Adapter_Abstract doesnt allow multiple parameters for validators in addValidator()

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Won't Fix
  • Affects Version/s: Next Major Release
  • Fix Version/s: 1.8.2
  • Component/s: Zend_File_Transfer
  • Labels:
    None

Description

Zend_File_Transfer_Adapter_Abstract does not properly implement adding validators with multiple parameters in their constructors.

line 335 of 1.8 beta 1:

$name      = $this->getPluginLoader(self::VALIDATE)->load($validator);
$validator = new $name($options);
if (is_array($options) && isset($options['messages'])) {
    if (is_array($options['messages'])) {
        $validator->setMessages($options['messages']);
    } elseif (is_string($options['messages'])) {
        $validator->setMessage($options['messages']);
    }

    unset($options['messages']);
}

this should be more similar to protected function _loadValidator(array $validator) in Zend_Form_Element:

if (empty($options)) {
    $validator = new $name;
} else {
    $messages = false;
    if (isset($options['messages'])) {
        $messages = $options['messages'];
        unset($options['messages']);
    }

    $r = new ReflectionClass($name);
    if ($r->hasMethod('__construct')) {
        $validator = $r->newInstanceArgs((array) $options);
    } else {
        $validator = $r->newInstance();
    }

    if ($messages) {
        if (is_array($messages)) {
            $validator->setMessages($messages);
        } elseif (is_string($messages)) {
            $validator->setMessage($messages);
        }
    }
}

Activity

Hide
Thomas Weidner added a comment -

Multiple parameters are per definition depreciated and will be erased within 2.0.
Existing validators allow also to give multiple parameters as array.

We should not implement a depreciated feature.

Show
Thomas Weidner added a comment - Multiple parameters are per definition depreciated and will be erased within 2.0. Existing validators allow also to give multiple parameters as array. We should not implement a depreciated feature.
Hide
Michael added a comment -

I understand your argument, but this means that current built in validators with multiple parameters such as InArray will not work until 2.0
Can the existing validators with multiple arguments be updated for 1.8?

Show
Michael added a comment - I understand your argument, but this means that current built in validators with multiple parameters such as InArray will not work until 2.0 Can the existing validators with multiple arguments be updated for 1.8?
Hide
Thomas Weidner added a comment -

What should a InArray validator check to a file ?
I see no usecase for this validator to be attached to a file.

When validators do not conform the usage with Zend_Config then these validators should be fixed.

Show
Thomas Weidner added a comment - What should a InArray validator check to a file ? I see no usecase for this validator to be attached to a file. When validators do not conform the usage with Zend_Config then these validators should be fixed.
Hide
Thomas Weidner added a comment -

Closing as won't fix.

Show
Thomas Weidner added a comment - Closing as won't fix.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: