ZF-7201: Zend_Form_Element_File::getValue() only works on first usage

Issue Type: Bug Created: 2009-07-06T04:41:39.000+0000 Last Updated: 2009-07-07T01:38:13.000+0000 Status: Resolved Fix version(s): - 1.9.0 (31/Jul/09)

Reporter: Daniel Thomas (dpool) Assignee: Thomas Weidner (thomas) Tags: - Zend_Form

Related issues: Attachments:


If you are accessing the ::getValue() function of Zend_Form_Element_File more than once during one PHP process only the first usage of the function will return the correct value of the element. All subsequent usages will return NULL. At the end I tried the calling the function on the consequtive lines - with above result.

The actual problem seems to lie in the Zend_File_Transfer_Adapter_Http::receive function. The Zend_Form_Element_File::receive() function only returns TRUE once. That's why Zend_Form_Element_File::geValue() will return NULL in LINE 711 on the second usage.


Posted by Thomas Weidner (thomas) on 2009-07-06T07:04:50.000+0000

I can negotate your bescribed reason.

receive() returns TRUE multiple times. The object stores if the file was already received or not, and in the case it has already been received a true is instantly returned without further checks.

BUT: When you create a new object then you will have the described behaviour, as the new object expects that the file is available, which is not the case as the first object already received the file.

Posted by Daniel Thomas (dpool) on 2009-07-06T23:57:10.000+0000

Then my trace of the problem to the transfer adapter seems to be wrong. Still I have the feeling that it should be possible to access the value of an instance of Zend_Form_Element_File more than once. Currently this behaviour is like follows:

Example: Upload of a file named "file.gif" via an file upload field named "image". Codesnippet:

// $form = new Zend_Form(); .... $value1 = $form->image->getValue(); $value2 = $form->image->getValue(); //

In this example $value1 is "file.gif" and $value2 is NULL. This wasn't the case in the 1.7.+ branch and actually broke part of my application after the upgrade to 1.8.4. I changed my application to use Zend_Form_Element_File::getFileName(null, false) instead of the ::getValue(). That works for the moment.

Posted by Thomas Weidner (thomas) on 2009-07-07T01:38:12.000+0000

Fixed with r16542

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.