Maybe a simple array_key_exists() or isset() before the if might solve this notice.

Comments

Posted by Thomas Weidner (thomas) on 2009-09-29T13:37:59.000+0000

When there is no CONTENT_LENGTH available then you have a web-server problem.
It should always be available as long as $_POST is here and you received data from a form.

And when POST does not exist you can not have a active upload.

Posted by Thomas Weidner (thomas) on 2009-09-29T14:29:52.000+0000

Feature added.

The HTTP protocol defines that CONTENT_LENGTH must be available in POST requests.Note that a missing CONTENT_LENGTH shows a broken web server.
So you should install the newest release of your webserver to get rid of this problem.

{quote}
...NOTICE messages will warn you about possible bugs in your code. For example, use of unassigned values is warned. It is extremely useful to find typos and to save time for debugging. NOTICE messages will warn you about bad style.
{quote}

In my opinion, the component might handle this notice.

Just for the records, the Zend_Form doesn't have a {{isPost()}} method. I believe you mean:

if ($this->getRequest()->isPost()) {
$element->receive();
}

This verification might be defined within the component as well.

Posted by Thomas Weidner (thomas) on 2009-09-30T13:00:53.000+0000

*) The code above does not show anything... there is no file upload done you just gave the code for rendering... not more not less.

*) The component does handle the notice. Otherwise this issue would not have been fixed for the next release.

*) Why and how should Zend_File_Transfer verify if the controller is called by post or not ? There is no connection between this components. Additionally Zend_File_Transfer can be called with Put, Delete, Ftp, Webdav or any other protocol. It is not fixed to Post. So this would not work.

In my opinion, there is a connection between Zend_File_Transfer_Adapter_Http and Zend_Controller_Request_Http, as Zend_File_Transfer_Adapter_Http uses an HTTP request as data source. Additionally, you can use the Zend_Controller_Request_Http {{isGet()}}, {{isPost()}}, {{isDelete()}} and {{isPut()}} methods ensure that the request holds the correct data - only for HTTP adapters.

Thanks.

Posted by Thomas Weidner (thomas) on 2009-09-30T14:04:06.000+0000

Line 124 you gave as error is from the isValid method.
This method is only called when you call isValid on the form.

Your code does not call this method, so there are things missing which you did not gave. That's what I mean with missing parts. The code you gave does not call isValid, so the notice itself is not thrown just by the code you gave.

And no, we will not limit Zend_File to Zend_Controller_Request_Http. Beside of the BC break this would mean, it would also add a limitation which is not necessary.

Actually I didn't proposed a limitation, I proposed just an additional validation, to handle a potential problem explicitly and avoid wrong usage. I don't see how this verification could limit others adapters.

Anyway, the subject of the issue was the notice message and it seems to be solved, thanks for your time.