ZF-4260: If zend_form_element_file is validated, and whole form isnt, the file is still uploaded to the dir

Description

Like in topic,

when we have a form with some validators, and the form doesnt validate, but file element validates, we end up with file being uploaded to the target dir, this is not expected behaviour, it leads to "orphaned" files if someone forgets to delete the file explictly.

Comments

ZF-4062 is the real issue here.

First off, the file upload will happen regardless of what we do; for us to get the request in the first place, the file has to have been transferred in the request. By default, however, files are uploaded to a system temporary directory (this is something PHP does, not ZF). It is up to you to run garbage collection over that directory periodically.

However, there is an additional piece of the puzzle we need to address. One of the validators actually does introspection over the $_FILES superglobal; a file element is not considered valid unless the entry for the file in $_FILES shows no errors. However, at this time, if that validator passes, then the file is transferred to its final resting place.

Thomas is working on decoupling the validation from the filtering withing Zend_File_Transfer and the File form element, and we will have a solution soon

Assigning to Thomas (close with ZF-4062)

No bug. New feature has been implemented with r11391.

Changing issues in preparation for the 1.7.0 release.