Issue Type: Bug Created: 2008-09-13T07:13:07.000+0000 Last Updated: 2008-10-10T14:41:45.000+0000 Status: Resolved Fix version(s): - 1.6.2 (13/Oct/08)
Reporter: Loic Bistuer (loic.bistuer) Assignee: Thomas Weidner (thomas) Tags: - Zend_File_Transfer
Related issues: Attachments: - File.php
Zend_Form_Element_File delegates to the Zend_File_Transfer_Adapter all the validation effort.
The problem is while Zend_File_Transfer_Adapter have a validation process that mostly mimics validation in Zend_Form, the two processes remain different.
Here is what we lose compared to the validation offered by Zend_Form_Element:
- no support for the breakChainOnFailure feature. (this is a big one) - can't add custom messages unless you are instantiating the validators by hand and calling their setMessages method. (not convenient) - the syntax of the array passed to setValidators is different than the one of the other Zend_Form_Element(s). (breaks consistency which is never good)
I attached the file 'validation.php' that highlights the difference of syntax between Zend_Form_Element_File and the one of the other Zend_Form_Elememt(s).
Another issue with Zend_Form_Element_File: unlike other elements derived from Zend_Form_Element it doesn't seem to honor paths defined by a call to addElementPrefixPath on its parent form. Found that out when I tried to overload the 'Errors' decorator, Zend_Form_Element_File was the only element to still use the default one.
I also attached the Form_Element_File that I use for now to overcome all the problems above until they are fixed. It doesn't have all the bells and whistles of Zend_File_Transfer_Adapter but it does the job. (I don't recommend people using it since it hasn't been much tested but if someone does: don't forget to manually add the 'Upload' validator to the list of validators). Just like the original one, it won't work if used in a form where isArray is true or inside of a subform.
I hope that helps
Posted by Thomas Weidner (thomas) on 2008-09-14T04:40:29.000+0000
Zend_File_Transfer does not mimic Zend_Form validation. Zend_File_Transfer was built with completly other targets than Zend_Form. Zend_Form does only use a small part of what Zend_File_Transfer was meant for. The reason is that Zend_File_Transfer has it's own needs, and any subcomponent using it has to match the requisists of it and look to add it's own requisists itself.
Regarding of your complete issue, it's never a good idea to add multi issues, in your case 5 completly different ones, in a single issue. And always look if there is already a existing issue before adding a new one.
Posted by Loic Bistuer (loic.bistuer) on 2008-09-14T07:04:30.000+0000
Thomas, I understand your points, I however grouped those issues because to me they all relate to delegating validation for file elements to Zend_File_Transfer, which as you say has been built with completely other targets than Zend_Form.
And indeed, not using Zend_File_Transfer does solve all of them at once.
Posted by Thomas Weidner (thomas) on 2008-09-14T10:09:11.000+0000
The system just eaten my complete answer so I have to shorten my comment:
First: We know that the component is far away from being finished. We have had to hurry to get it ready for 1.6 so much things are missing and will be added. Each release will add new features. We are aware of this and know the problematic.
Second: Your implementation is a security headache. I must strictly warn about using it. By using a manual implementation you first loose all benefits of Zend_File_Transfer, for example validators and filters. And, this is the greater neg, you will have massive security problems with your solution. Do not use such an implementation in productive environment.
Zend_Form handles Form creation. Zend_File_Transfer handles file uploads and downloads, and it knows the security problems and handles them for you.
Posted by Thomas Weidner (thomas) on 2008-09-19T02:31:16.000+0000
The breakChainOnFailure feature has been added. See ZF-4205 and r11430.
Posted by Thomas Weidner (thomas) on 2008-09-21T02:15:27.000+0000
All described issue are eigther solved or already filed by other issues.
The only open this is what you've mentioned with addElementPrefixPath. Please give some code for reproduction so we can see and test the problem.
Posted by Loic Bistuer (loic.bistuer) on 2008-09-21T05:02:45.000+0000
Thomas, I couldn't reproduce the addElementPrefixPath bug; I can't remember exactly what I did to get this outcome. We can close this issue, I'll submit another one along with sample code if I come across this problem again.
Concerning my implementation of Zend_Form_Element_File above, it was indeed not ready for production and was a simple proof of concept to illustrate what I was saying. Though, unlike what you said it does handle most of the validation done in the current Zend_Form_Element_File implementation (granted that you don't forget to add manually Zend_Validate_File_Upload to the list of validators).
Posted by Thomas Weidner (thomas) on 2008-09-21T05:28:40.000+0000
I will then close this issue. All other mentioned problems or features have already be integrated to trunk.
Thanks for your report.
Posted by Thomas Weidner (thomas) on 2008-09-21T05:30:29.000+0000
Problems resolved, eighter in seperate issues, or by independend enhencements of the components.
Please fill in a new issue if something is not fixed.
Have you found an issue?
See the Overview section for more details.