ZF-4386: Issue with ignoreNoFile in Zend_File_Transfer_Adapter_Abstract

Issue Type: Bug Created: 2008-09-26T04:21:53.000+0000 Last Updated: 2008-11-13T14:10:10.000+0000 Status: Resolved Fix version(s): - 1.7.0 (17/Nov/08)

Reporter: malt (malt) Assignee: Thomas Weidner (thomas) Tags: - Zend_File_Transfer

Related issues: - ZF-4388

Attachments: - demo.php


I discovered an issue with the ignoreNoFile option in the isValid() function in Zend_File_Transfer_Adapter_Abstract. The current problematic code ( latest trunk ) looks like this:

<pre class="highlight">
if ($this->_options['ignoreNoFile'] and (isset($fileerrors['fileUploadErrorNoFile']))) {
if (($class === 'Zend_Validate_File_Upload') and (count($fileerrors) > 0)) {

From what i understand, the validation chain will be stopped if there was an error in the Upload validator. In case i use the ignoreNoFile option and i submit the form without uploading a file, all further validation after the Upload validator should be skipped.

With the current code, this is never happen, because the fileUploadErrorNoFile entry in the errors array will be removed earlier. To fix this, the code could be changed to this:

<pre class="highlight">
// error in the upload validator so stop validating
if (($class === 'Zend_Validate_File_Upload') and (count($fileerrors) > 0)) {
    // file element is not required and no file was uploaded so remove the error message 
    if ($this->_options['ignoreNoFile'] and (isset($fileerrors['fileUploadErrorNoFile']))) {


Posted by Thomas Weidner (thomas) on 2008-09-26T05:43:16.000+0000

Your change brakes option for other adapters than HTTP. Please give code for reproduction.

Posted by malt (malt) on 2008-09-26T06:44:58.000+0000

small test application

Posted by malt (malt) on 2008-09-26T06:46:16.000+0000

Added a small test application. I also made some notes about issue ZF-4347, which can be tested with this app, too.

Posted by Thomas Weidner (thomas) on 2008-09-26T08:49:30.000+0000

Great demo app... Thanks ( I hope every commiter would be able to add such ;-) )

But when I submit the form without any file set, it returns to me "FORM VALID".

Maybe your repository is not up to date or broken ? Simply try to update to actual trunk.

Posted by Thomas Weidner (thomas) on 2008-09-28T08:20:13.000+0000

Closing issue due to non-response

Posted by malt (malt) on 2008-09-29T01:00:56.000+0000

So i made a fresh export from the trunk and you are right, submitting without any file set works as intended.

However i still have problems with the validators and multiple file elements. I dont get the messages i should get, so will investigate a bit further. Should i open a new issue for this then?

Posted by Thomas Weidner (thomas) on 2008-09-29T01:48:28.000+0000

When the issue is related to ignoreNoFile feel free to reopen this one. If you are getting a different issue, then please create a new one.

Issues should always be related to a single problem.

Posted by l c (cromulent) on 2008-10-19T15:23:10.000+0000

Wasn't sure if I should create a new ticket or comment on this one, but the check for ignoreNoFile is still flawed in 1.6.2

I had an issue where move_uploaded_file was failing and the specific file element was set to required. As a result, receive should be returning a value of false. However, the following line caused the error from move_uploaded_file to be skipped inside of the receive method in Zend_File_Transfer_Adapter_Abstract.php

<pre class="highlight">
if (isset($this->_options['ignoreNoFile'])) {

This basic check to see if ignoreNoFile exists is not enough to tell the validation to skip errors because ignoreNoFIle is being set by default, but it's value is set to a boolean of false when you set an element to be required. In addition to checking if the options index exists, it should also check the boolean value of the option and only continue if it's true.

Posted by Thomas Weidner (thomas) on 2008-10-20T03:30:17.000+0000

Yes, you are true. thank you for mentioning this.

Fixed with r12027

Posted by Wil Sinclair (wil) on 2008-11-13T14:10:10.000+0000

Changing issues in preparation for the 1.7.0 release.

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.