ZF-11710: Zend_Filter_Input considers empty Arrays as valid data

Issue Type: Bug Created: 2011-08-30T19:33:48.000+0000 Last Updated: 2012-03-05T23:13:18.000+0000 Status: Open Fix version(s): Reporter: Lucas Corbeaux ( Assignee: Ralph Schindler (ralph) Tags: - Zend_Filter_Input

  • zf-crteam-review

Related issues: - ZF-4379

Attachments: - filter-input-empty-array.patch


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 :

<pre class="highlight"><?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.


Posted by Lucas Corbeaux ( on 2011-08-30T19:36:49.000+0000

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 :)

Posted by Matthew Weier O'Phinney (matthew) on 2011-08-30T20:16:20.000+0000

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.

Posted by Lucas Corbeaux ( on 2011-08-30T20:50:13.000+0000

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

Posted by Lucas Corbeaux ( on 2011-09-01T19:06:33.000+0000

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.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.