ZF-10082: Zend_File_Transfer_Adapter_Http::getProgress() not working well with uploadprogress
Description
Zend_File_Transfer_Adapter_Http::getProgress() doesn't work well in combination with "PECL uploadprogress", because the $_GET value "progress_key" is never set by this module.
The point is, that you have to set the value manually to make it work:
//WORKS AS EXPECTED: $x = uploadprogress_get_info($parUploadId);
//MANUALLY ADD TO MAKE IT WORK: $_GET['progress_key'] = $parUploadId;
require_once 'Zend/ProgressBar/Adapter/JsPush.php'; $adapter = new Zend_ProgressBar_Adapter_JsPush(); //ALWAYS RETURNS null WITHOUT THE CORRECTION ABOVE: $upload = Zend_File_Transfer_Adapter_Http::getProgress();
$upload = null; while (!$upload['done']) { //ALWAYS RETURNS null WITHOUT THE CORRECTION ABOVE: $upload = Zend_File_Transfer_Adapter_Http::getProgress($upload); var_dump($upload); }
Furthermore you should please add some documentation which hidden fields (and in which order) should be contained in the form, not only mention that Zend_Form adds it automatically. Not everyone uses it!
Please fix this issue so that the described workaround is no more needed. Without this hack the module never works.
Comments
Posted by Thomas Weidner (thomas) on 2010-07-03T11:14:39.000+0000
The manual of uploadprogress notes which hidden fields have to be set. Additionally there is an full example within the ZF demo section which shows how to use this external module manually within ZF.
The ZF manual itself is witten to be used with Zend_Form. Still it notes:
This is no hack... Zend_Form adds this form fields automatically and you are not using Zend_Form. How should Zend_File_Transfer add form fields? Your intention is in my eyes unlogically.
Which hidden fields you have to add belongs on the used extension and it's version as also on the used settings for this extension.
Posted by Thomas Weidner (thomas) on 2010-07-04T12:28:04.000+0000
Closing as non-issue.
The hidden key "progress_key" is not necessary for the uploadprogress extension to work. It is used internally by Zend_Form_Element. You can use any key you want. Look at the demo implementation to see how this works.
Posted by Julian Pustkuchen (anybody) on 2010-07-04T12:59:27.000+0000
Sorry but I think you didn't get me or just didn't test the tool correctly with uploadprogress.
Firstofall of course the manual of uploadprogress mentions which hidden fields to set, but please try, it doesn't work with Zend_File_Transfer if you do so. Of course progress_key is not necessary for uploadprogress, but for Zend Frameworks implementation it is! As you should know Zend_Framework is no full stack framework and if this part does not work without using Zend_Form then for ... sake DOCUMENT the magic behaviour and this required field!
The reason is (please just debug one time to see and not only say what you THINK, not knowing what really happens in the code logically). In the next lines I'm referring to the documentation, just as you wanted me to do:
HTTP.php (~Line 335): //ID can't be set yet, because at first call it is the Adapter -> unset before if (empty($id)) { if (!isset($_GET['progress_key'])) { $status['message'] = 'No upload in progress'; $status['done'] = true; } else { $id = $_GET['progress_key']; } }
So please tell me what will happen if you do not use Zend_Form and don't use my workaround ;) And believe me... this is not just a guess, I wasted several hours with this!
If this should be the right behaviour, please have another look at the documentation:
After the first "getProgress" the upload is set to null, what happens? The same again for one more time (but for the last, because after this 'done' is true). If you don't set upload to null on the other hand, it is true immediately and so the while-loop never runs.
Please don't get me wrong, everybody makes mistakes and that is OK! But why can't you just document this? Everything would be fine, you don't even have to fix it if you think that it is OK.
This is my last statement, anyway you think about it or test it or leave it like it is, but I thougt that Zend Framework is professional, I'm really disapointed.
I wasted several hours, furthermore documented it here for you and you just seem to say... this can't be the point,... no, thats not what I expect from a Zend FW developer. I apologize, if it's wrong what I pointed out before, but I really don't think so.
Posted by Thomas Weidner (thomas) on 2010-07-12T15:05:28.000+0000
There is no mistake at all.
When you are using a manual self defined key then you simply must give that key to getProgress(). That's how uploadprogress shows how it works itself. And that's also how APC defines how it works itself.
Normally you also do upload_get_info($unique_key); when using the extension manually. And when using getProgress() instead it must have the same key... getProgress($unique_key)
I don't see this as failure and there is no need to use a workaround to make this work. As I said before you can use ANY self defined key.
The point is that Zend_File_Transfer allows to use both extensions. Yes... independently from Zend_Form. But still you should know how these two extensions work. Both projects have their own documentation. And it will not be duplicated by ZF.
Posted by Thomas Weidner (thomas) on 2010-11-22T11:43:15.000+0000
Correct fix version as it has been deleted unintentionally by another user