Re: [fw-general] Breakchain on Zend_Form_Element_File fail
Ok I just saw those issues, Thank you for your time and informations, Yann Thomas Weidner a écrit : You just say what is already described in the manual. And looking at our issue list you would have mentioned that we will also add a content-type validator which checks the stored content, as the mime-type can be changed by users. As I already wrote several times, this component is not finished and under continous development. However, Apache, for example provides related modules which DO handle this also for the mime-type. Greetings Thomas Weidner, I18N Team Leader, Zend Framework http://www.thomasweidner.com
Re: [fw-general] Breakchain on Zend_Form_Element_File fail
You just say what is already described in the manual. And looking at our issue list you would have mentioned that we will also add a content-type validator which checks the stored content, as the mime-type can be changed by users. As I already wrote several times, this component is not finished and under continous development. However, Apache, for example provides related modules which DO handle this also for the mime-type. Greetings Thomas Weidner, I18N Team Leader, Zend Framework http://www.thomasweidner.com - Original Message - From: "Yann Thomas-Gérard" <[EMAIL PROTECTED]> To: Sent: Thursday, September 25, 2008 5:02 PM Subject: Re: [fw-general] Breakchain on Zend_Form_Element_File fail Yann Thomas-Gérard a écrit : Nice, but you can not rename the file yourself. Validation is done on the temporary file, then the file is moved and then the filter is attached. What I meant was: If I click on my navigator's browse button and select the 'a.jpg' file from my harddisk, validation passes. So when you rename the file, you rename it after validation and filtering. There is no processing after that point. To resume, I got $breakChainOnFailure to work with the latest trunk. As for the MimeType validator, I think it checks the type in the files array from php. This info is not reliable: From http://fr.php.net/manual/en/features.file-upload.php [...] $_FILES['userfile']['type'] The mime type of the file, if the browser provided this information. An example would be "image/gif". This mime type is however not checked on the PHP side and therefore don't take its value for granted. [...] It could probably be better with this PECL extension: http://fr.php.net/manual/en/ref.fileinfo.php
Re: [fw-general] Breakchain on Zend_Form_Element_File fail
Yann Thomas-Gérard a écrit : Nice, but you can not rename the file yourself. Validation is done on the temporary file, then the file is moved and then the filter is attached. What I meant was: If I click on my navigator's browse button and select the 'a.jpg' file from my harddisk, validation passes. So when you rename the file, you rename it after validation and filtering. There is no processing after that point. To resume, I got $breakChainOnFailure to work with the latest trunk. As for the MimeType validator, I think it checks the type in the files array from php. This info is not reliable: From http://fr.php.net/manual/en/features.file-upload.php [...] $_FILES['userfile']['type'] The mime type of the file, if the browser provided this information. An example would be "image/gif". This mime type is however not checked on the PHP side and therefore don't take its value for granted. [...] It could probably be better with this PECL extension: http://fr.php.net/manual/en/ref.fileinfo.php
Re: [fw-general] Breakchain on Zend_Form_Element_File fail
Nice, but you can not rename the file yourself. Validation is done on the temporary file, then the file is moved and then the filter is attached. What I meant was: If I click on my navigator's browse button and select the 'a.jpg' file from my harddisk, validation passes. So when you rename the file, you rename it after validation and filtering. There is no processing after that point. Nice to know, Yann
Re: [fw-general] Breakchain on Zend_Form_Element_File fail
Nice, but you can not rename the file yourself. Validation is done on the temporary file, then the file is moved and then the filter is attached. So when you rename the file, you rename it after validation and filtering. There is no processing after that point. Greetings Thomas Weidner, I18N Team Leader, Zend Framework http://www.thomasweidner.com - Original Message - From: "Yann Thomas-Gérard" <[EMAIL PROTECTED]> To: Sent: Thursday, September 25, 2008 10:39 AM Subject: Re: [fw-general] Breakchain on Zend_Form_Element_File fail Yes I was using an outdated version. The breakChainOnFailure works fine now. Thanks! May I point out that with 'a.txt' validation works. If I rename 'a.txt' to 'a.jpg' then validation passes. This not what I expect. FYI: $ file -i a.txt a.txt: text/plain; charset=us-ascii $ file -i a.jpg a.jpg: text/plain; charset=us-ascii Yann Sorry, but I still think that you are using an outdated revision. Trunk revision works. I tested it myself yesterday. Please keep in mind that this component is actually under development and things change very fast. So it could be that a failure from a week before is already solved, or I notice something no one has got until now and I fix it without any note or issue. Greetings Thomas Weidner, I18N Team Leader, Zend Framework http://www.thomasweidner.com
Re: [fw-general] Breakchain on Zend_Form_Element_File fail
Yes I was using an outdated version. The breakChainOnFailure works fine now. Thanks! May I point out that with 'a.txt' validation works. If I rename 'a.txt' to 'a.jpg' then validation passes. This not what I expect. FYI: $ file -i a.txt a.txt: text/plain; charset=us-ascii $ file -i a.jpg a.jpg: text/plain; charset=us-ascii Yann Sorry, but I still think that you are using an outdated revision. Trunk revision works. I tested it myself yesterday. Please keep in mind that this component is actually under development and things change very fast. So it could be that a failure from a week before is already solved, or I notice something no one has got until now and I fix it without any note or issue. Greetings Thomas Weidner, I18N Team Leader, Zend Framework http://www.thomasweidner.com
Re: [fw-general] Breakchain on Zend_Form_Element_File fail
Sorry, but I still think that you are using an outdated revision. Trunk revision works. I tested it myself yesterday. Please keep in mind that this component is actually under development and things change very fast. So it could be that a failure from a week before is already solved, or I notice something no one has got until now and I fix it without any note or issue. Greetings Thomas Weidner, I18N Team Leader, Zend Framework http://www.thomasweidner.com - Original Message - From: "Yann Thomas-Gérard" <[EMAIL PROTECTED]> To: Sent: Thursday, September 25, 2008 9:57 AM Subject: Re: [fw-general] Breakchain on Zend_Form_Element_File fail Thomas Weidner a écrit : Well... I think that when there is no error by validation $this->_messages is empty... So why should the chain break when there is no failure ? There are errors by validation when I upload an ascii file: * The file 'a.txt' has a false mimetype * The file 'a.txt' has a false extension This is expected behaviour. Only when there is a validation error all further validations are supressed. Yes, this what I expect too. Yann
Re: [fw-general] Breakchain on Zend_Form_Element_File fail
Thomas Weidner a écrit : Well... I think that when there is no error by validation $this->_messages is empty... So why should the chain break when there is no failure ? There are errors by validation when I upload an ascii file: * The file 'a.txt' has a false mimetype * The file 'a.txt' has a false extension This is expected behaviour. Only when there is a validation error all further validations are supressed. Yes, this what I expect too. Yann
Re: [fw-general] Breakchain on Zend_Form_Element_File fail
Well... I think that when there is no error by validation $this->_messages is empty... So why should the chain break when there is no failure ? This is expected behaviour. Only when there is a validation error all further validations are supressed. Greetings Thomas Weidner, I18N Team Leader, Zend Framework http://www.thomasweidner.com - Original Message - From: "Yann Thomas-Gérard" <[EMAIL PROTECTED]> To: Sent: Wednesday, September 24, 2008 6:02 PM Subject: Re: [fw-general] Breakchain on Zend_Form_Element_File fail Thomas Weidner a écrit : I think that you should use the trunk to have this feature working. Breakchainonfailure has been added a few days ago for the file element. Hi Thomas, With the trunk, I still can't get it to work and although the adapter's addValidator now receives $breakChainOnFailure. I think there's an error in the isValid method in Zend/File/Transfer/Adapter/Abstract.php. The test: if (($this->_break[$class]) and (count($this->_messages) > 0)) { $break = true; break; } is never true because of the count($this->_messages) always to zero. If I do this: if ($this->_break[$class]) { $break = true; break; } Then the file element is always valid and that is an error too. Again, what do you think ? Thanks, Yann
Re: [fw-general] Breakchain on Zend_Form_Element_File fail
Thomas Weidner a écrit : I think that you should use the trunk to have this feature working. Breakchainonfailure has been added a few days ago for the file element. Hi Thomas, With the trunk, I still can't get it to work and although the adapter's addValidator now receives $breakChainOnFailure. I think there's an error in the isValid method in Zend/File/Transfer/Adapter/Abstract.php. The test: if (($this->_break[$class]) and (count($this->_messages) > 0)) { $break = true; break; } is never true because of the count($this->_messages) always to zero. If I do this: if ($this->_break[$class]) { $break = true; break; } Then the file element is always valid and that is an error too. Again, what do you think ? Thanks, Yann
Re: [fw-general] Breakchain on Zend_Form_Element_File fail
I think that you should use the trunk to have this feature working. Breakchainonfailure has been added a few days ago for the file element. Greetings Thomas Weidner, I18N Team Leader, Zend Framework http://www.thomasweidner.com - Original Message - From: "Yann Thomas-Gérard" <[EMAIL PROTECTED]> To: Sent: Wednesday, September 24, 2008 4:12 PM Subject: [fw-general] Breakchain on Zend_Form_Element_File fail Hello, With ZF 1.6.1, I can't get the validator breakchain to work on a file element: private function getAvatar() { $el = $this->createElement('file', 'avatar'); $el ->setLabel('Upload an avatar:') ->setRequired(false) ->setDestination(UPLOAD_PATH) ->addValidator('Count', true, 1) ->addValidator('Size', true, 102400) ->addValidator('MimeType', true, array('image/gif', 'image/jpeg', 'image/png')) ->addValidator('Extension', true, array('gif', 'jpg', 'png')); return $el; } In Zend/Form/Element/File.php, I see: /** * Add Validator; proxy to adapter * * @param string|Zend_Validate_Interface $validator * @param bool $breakChainOnFailure * @param mixed $options * @return Zend_Form_Element_File */ public function addValidator($validator, $breakChainOnFailure = false, $options = array()) { $adapter = $this->getTransferAdapter(); $adapter->addValidator($validator, $options); return $this; } $breakChainOnFailure is never passed to the adapter's addValidator. What do you think ? Thanks, Yann
[fw-general] Breakchain on Zend_Form_Element_File fail
Hello, With ZF 1.6.1, I can't get the validator breakchain to work on a file element: private function getAvatar() { $el = $this->createElement('file', 'avatar'); $el ->setLabel('Upload an avatar:') ->setRequired(false) ->setDestination(UPLOAD_PATH) ->addValidator('Count', true, 1) ->addValidator('Size', true, 102400) ->addValidator('MimeType', true, array('image/gif', 'image/jpeg', 'image/png')) ->addValidator('Extension', true, array('gif', 'jpg', 'png')); return $el; } In Zend/Form/Element/File.php, I see: /** * Add Validator; proxy to adapter * * @param string|Zend_Validate_Interface $validator * @param bool $breakChainOnFailure * @param mixed $options * @return Zend_Form_Element_File */ public function addValidator($validator, $breakChainOnFailure = false, $options = array()) { $adapter = $this->getTransferAdapter(); $adapter->addValidator($validator, $options); return $this; } $breakChainOnFailure is never passed to the adapter's addValidator. What do you think ? Thanks, Yann