Multiple AJAX File uploads in one form breaks for anonymous user

Created on 20 August 2016, almost 8 years ago
Updated 8 February 2024, 4 months ago

Issue crosses between caching, forms, AJAX, and file.

Issue appears in 7.50 when an anonymous user comes to a form (noticed in webform and enitityform, though I suppose you could have an anonymous accessible /node/add or comment form) with multiple AJAX file uploaders. System has page caching on. The anonymous user uploads to one File field successfully. She tries to upload a file in the second File field. Returns "An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (2 MB) that this server supports."

Reproduction: stock 7.50. Enable webform and its dependencies. Create a webform with two File upload fields. Enable basic page caching. Log out and access form as anonymous. Attempt to upload files in both File fields. (browser must have JS enabled). Second upload will give the "An unrecoverable error occurred" dialog.

The problem: because the form was anonymous/cached, the DOM-inserting (fid_token) code in 6b6bc1b7 ends up updating the form_build_id value on the containing form via the AJAX callback. (Search for 'immutable' in form.inc). Okay. However, the submission of the other AJAX form (the other File field) still gets sent to the AJAX POST endpoint of the old and bad form_build_id. Basically, the AJAX update of the form_build_id doesn't modify the target POST addresses in other AJAX forms, and they aren't generating their POST locations on the fly.

D8: While 2678822 had a similar fix in D8.1.1, the POST endpoints are not based on form_build_id, so it doesn't appear to be a problem.

Quick workaround: cacheexclude pages that are affected (i.e., the entityform in our case).

Still thinking a bit on a more proper solution.

πŸ› Bug report
Status

Closed: duplicate

Version

7.0 ⚰️

Component
File moduleΒ  β†’

Last updated 3 days ago

Created by

πŸ‡ΊπŸ‡ΈUnited States tshorock

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024