Currently the system uses either: PECL uploadprogress http://pecl.php.net/package/uploadprogress or APC rfc1867 to show file upload progress (neither of which work with PHP 7 and nginx).
There was a discussion here https://www.drupal.org/node/1561866 about using the built in php session upload progress (PHP 5.4+) however Drupal's implementation of PHP session seems to interfere with this in a lot of cases.
https://www.drupal.org/u/droplet suggested that as D8 uses the jQuery.form plugin, it's proposed that we remove the reliance on 3rd party PHP libraries in the built in session upload progress and go with a the jQuery.form client side solution.
I have attached a patch that implements this and removes the old solutions.
It definitely needs review and some additional work (I would like this to work with remote file systems and CORS upload eventually).
Tested with Apache2 and nginx in Chrome (latest version).
I suspect there may be issues with Internet Explorer 9 compatibility. Does anyone know if there is a fallback built into jQuery.form to handle this?
Comment | File | Size | Author |
---|---|---|---|
#73 | upload_progress-2833968-73.patch | 7.78 KB | chucksimply |
#71 | 2833968-71.patch | 9.34 KB | pradhumanjain2311 |
#68 | upload_progress-2833968-68.patch | 7.79 KB | kyriazo |
#67 | upload_progress-2833968-67.patch | 7.75 KB | brunodbo |
Issue fork drupal-2833968
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
rjjakes CreditAttribution: rjjakes commentedComment #4
andypostLooks great, only fix tests left and approval about backward compatibility
not clear is this this needed?
maybe some setting still can block that?
Comment #5
rjjakes CreditAttribution: rjjakes commentedHi @andypost, I'll do the test fix later today when I get chance.
I wasn't sure if we should keep the entry on the status page either. Perhaps it would be useful as an indicator that things have change (then we can plan to remove it completely for a much later release?)
Comment #6
droplet CreditAttribution: droplet commentedThanks @rjjakes !
We can keep current PHP code as BC layer. (Until we have a final decision: #2390621: [policy, no patch] Update Drupal's browser support policy)
It's 100% client-side. We can drop it I think.
Might be we only tell it doesn't work in older IE & browser do not support ProgressEvent..
Comment #7
droplet CreditAttribution: droplet commentedComment #8
rjjakes CreditAttribution: rjjakes commented@droplet - I made the call back to the fileprogress endpoint (core/modules/file/src/Controller/FileWidgetAjaxController.php in this case) with additional data to keep as much of the existing code in place as possible. Are you saying I should drop this in favour of a purely client side solution? If so, this is significantly more refactoring and has the potential to break the batch progress too.
I think we should keep it as is (calling back via AJAX to core/modules/file/src/Controller/FileWidgetAjaxController.php) to maintain consistency.
Comment #9
rjjakes CreditAttribution: rjjakes at Acquia Site Studio commentedUpdated credit.
Comment #10
rjjakes CreditAttribution: rjjakes commentedComment #14
steveoriolHello rjjakes,
Thank you, after patched by hand 3 files on D8.3.7 , It is working good :-)
Comment #15
steveoriolHere is the patch for D8.3.7
Comment #17
brunodboRerolled the patch in #15 for 8.6.x; it also applies to 8.5.3.
Comment #19
brunodboFixing coding standards.
Comment #22
quicksketchWe've ported this implementation over to Backdrop in https://github.com/backdrop/backdrop-issues/issues/3211.
I don't think there's any need for the new `setProgressdata()` method or to call it here. The progress object already has a `setProgress()` method that could just move the progress bar.
The Backdrop implementation also takes @_nod's suggestion and just switches the implementation to be entirely client-side. If you'd like to continue supporting old browsers, Backdrop lets uploadprogress or APC (if available) take precedence, but honestly the client-side only implementation is better all around. Browser support is very good at this point: https://caniuse.com/#feat=xhr2
Comment #23
brunodboTo keep this going, here's a reroll of the patch in #19 against 8.7.x. Also applies against 8.6.x.
Comment #24
brunodboAs suggested in #22, this patch uses
setProgress()
to move the progress bar instead of a newly addedsetProgressdata()
method.Comment #26
jerrylow CreditAttribution: jerrylow commentedGetting an error when the file upload is set to throbber rather than progress bar.
Comment #27
jerrylow CreditAttribution: jerrylow at Myplanet commentedOops uploaded the wrong patch.
Comment #28
steveoriolHello,
the patch applies well, the progress bar is also displayed,
but it remains motionless at the beginning without growing until the end of the file upload(I forgot to empty the cache) ...If I go back to the network tab of the dev tools, I have progress requests that go well,
but the answer is always:
{"message": "Starting upload ...", "percentage": - 1}
it is as if the GET 'loaded' and 'total' variables were not sent or received.
But why always use the return json if the code uses the function "setProgress (percentage, message, label)" by now ?
I put a:
console.log ('percentage:' + percentage + ', message:' + message + ', label:' + label);
in the "setProgress" function and I have the following:
why, the ligne "percentage:-1 , message:Starting upload... , label:undefined" ?
why message never indicate "Uploading... (@current of @total)" ?
Comment #29
steveoriolHello again,
I modified the last patch to work at home on D8.7.2 (to display the message above the progress bar), it's probably not very good coding, but it works, do not hesitate to rot and make the changes you need ;-)
Comment #31
steveoriolI removed too many things in my last patch and the progress bar for something other than images no longer function (update translation, etc.)
Here is the new one.
Comment #32
Alex Pshegodskyi CreditAttribution: Alex Pshegodskyi commentedThank you for your patch, it work great for upload using regular drupal forms, but not working when uploading file using file manager, any idea how to make it work in file manager too?
Comment #34
Tim Bozeman CreditAttribution: Tim Bozeman at CyberSolution for Tag1 Consulting commentedRerolled for 8.8.
Comment #35
steveoriolHello,
The patch applies well, but on my side the progress bar remains glued to the left until the document has finished downloading ...
Comment #36
steveoriolThis patch works for me, by added "ajax.uploadProgress" inside the 2 js files...
Comment #38
Tim Bozeman CreditAttribution: Tim Bozeman at CyberSolution for Tag1 Consulting commentedThanks Steve!
Whoops. @douggreen pointed out that the re-roll left a bit of cruft.
Comment #40
steveoriolReview OK for me with patch 38 :-)
Comment #41
brunodboI noticed a PHP notice on the Status report, this patch should fix that.
Comment #42
brunodboComment #44
andypostSadly no interdiffs in last patches...
Are you sure that TB is enough? The core's `
format_size()
` function provides 4 more and makes them translatableComment #45
joelpittetHere's the interdiff between 38-41, it's small enough to not need a file.
Comment #46
Neslee Canil PintoComment #48
Neslee Canil PintoComment #49
jungleTests did not pass
Comment #50
joelpittetI'm wondering since we seem to be moving away from jQuery UI and maybe jQuery too, that we could use something like this:
https://htmldom.dev/upload-files-with-ajax/
Feel free to punt me to a new issue if that is diverging too far from this issues scope.
Comment #54
steveoriolPatch #46 still works on D9.2.7 :-)
Comment #57
chucksimply CreditAttribution: chucksimply commentedJust want to confirm... patch #46 works on 9.4.5.
I tried for months trying to get PECL uploadprogress package working on my server and drupal site. Never could. This patch was such a simple solution.
Would be great to get a new patch file that passes tests. And move forward on getting it into core.
Comment #58
andypostIt makes sense to ind replacement as core is getting rid of jquery
Comment #60
steveoriolPatch update for D9.5.0
Comment #61
Nitin shrivastava CreditAttribution: Nitin shrivastava at OpenSense Labs commentedtry to fix #60
Comment #62
steveoriolNew try to pass test...
There are always some mistakes :-(
But still, the patch works well for D9.5.0.
And for D10, the patch generated from the "merge request !3190" also works.
D10 patch : https://git.drupalcode.org/project/drupal/-/merge_requests/3190.patch
Comment #65
smustgrave CreditAttribution: smustgrave at Mobomo commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
MR had a CI failure and still needs tests.
Hiding the files to avoid confusion.
Comment #67
brunodboThis is a reroll of #62 for 11.x, which also applies to 10.1.x. I'm getting an error when trying to create an interdiff that I'm unable to figure out at the moment (interdiff fails to process the patch files for some reason). This patch a straight reroll of the patch in #62. The only change is that I omitted the Drupal version number in the changes to
file_requirements()
, and in the comment forfile_progress_implementation()
.Do we need the file_requirements() at all? There is no system information to display anymore on the status report, so we could remove that message.
Leaving as needs work for tests.
Comment #68
kyriazo CreditAttribution: kyriazo as a volunteer commentedThis is a re-roll of patch #67 works but gives an error since SystemManager's listRequirements method expects a title on the requirement and gives an error on 10.1.x.
Comment #69
KlemenDEV CreditAttribution: KlemenDEV as a volunteer and at Pylo commentedIs this related to https://www.drupal.org/project/drupal/issues/1561866?
Comment #70
steveoriolPatch #68 works for me on D10.1.6 😀
Comment #71
pradhumanjain2311 CreditAttribution: pradhumanjain2311 at OpenSense Labs for DrupalFit commentedFix Patch not apply for 11.x
Comment #72
smustgrave CreditAttribution: smustgrave at Mobomo commentedPlease include interdiffs with patches, also encouraged to start using MRs instead.
Seems this was tagged for tests which reroll didn't have
Comment #73
chucksimply CreditAttribution: chucksimply commented#68 doesn't apply to 10.2, and #71 applies to 10.2 but doesn't show progress correctly (bar just goes straight to 100%).
Here is a new working patch based on #68 for 10.2.