ZF-11710: Zend_Filter_Input considers empty Arrays as valid data

Description

When an empty array is given to a Zend_Filter_Input for validation, it's considered as not empty and isValid() method returns true.

Here is a simple snippet that reproduce the bug :

<?php
require_once 'Zend/Filter/Input.php';
require_once 'Zend/Validate/NotEmpty.php';
 
$input = new Zend_Filter_Input(null, array('test' => array()));
$input->setData(array('test' => array()));

if ($input->isValid()) {
    echo "Array is not empty\n";
} else {
    echo "Array is empty\n";
}

$input->setData(array('test' => ''));

if ($input->isValid()) {
    echo "String is not empty\n";
} else {
    echo "String is empty\n";
}

It will display : Array is not empty String is empty

As Zend_Validate_NotEmpty, Zend_Filter_Input should considers that an empty array is an empty value, and is not valid.

Comments

I made a little patch that seems to solve the problem and that don't break unit tests, but it seems that I can't add an attachment. If anyone tell me how, I'll put it here :)

You need to have signed a CLA in order to attach files. The reason is that we cannot apply patches coming from non-CLA'd sources. Once you have, you should see the "Attach Files" entry under the "More Actions" dropdown at the top of the issue.

Thank you for your answer, I thought CLA was only needed for commiting, not for attaching files. I'm taking care of it quickly.

Here is a patch that works for me applied on the 1.11.10 tag.

With this little "fix", empty arrays given to Zend_Filter_Input are no longer considered as valid.