I have a webform with multiple pages, set to save draft on pressing prev/next (or the save draft btn). The form has many fields including 3 mandatory file upload fields on one page.
Normally when a person starts the form and then saves, logs out, and comes back later to continue, they are returning to the same instance of their form - so you only ever see 1 draft per drupal account on the results screen.
What's happening with out form is that each time the attachments are changed a new copy of the draft is saved for that user, so you end up with multiple drafts for the same Drupal user in the results list.
The user is always directed to the most recently saved version of their form when they log in and go to the webform, so it's not a huge problem - but makes the results tab messy and can definitely be classed as a bug.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | webform-file_upload_loses_sids-1819522-14.patch | 618 bytes | pete80 |
| #9 | webform_duplicate_on_upload-1819522.patch | 423 bytes | quicksketch |
| #4 | webform-file_upload_loses_sids-1819522-4.patch | 619 bytes | grahamc |
Comments
Comment #1
kmcculloch commentedI am noticing this behavior as well. I replicated my webform in a clean Drupal 7.14 installation to test. Nothing is enabled except standard core modules and webform.
Form setup details:
6 page form
Mandatory textarea fields on pages 1-4 and 6
Mandatory file upload on page 5
file type limited to "pdf"
"save draft" button enabled
save as draft between pages enabled
form limited to 1 submission per user ever
form access limited to authenticated users
Testing process:
I do a test submission, moving through the form step by step, entering sample text in each textarea. I browse for a "pdf" and upload it into the mandatory file field. I do not use the "Save Draft" or the "Previous Page" buttons. I submit the form.
Expected result:
A single completed submission including all textarea values and a link to the uploaded file.
Actual result:
A single draft submission including textarea values for pages 1-4. (Submission ID is #1.)
A single completed submission including all textarea values and a link to the uploaded file. (Submission ID is #2.)
Incidentally, I checked the files/webform directory and can confirm that the file was uploaded once and only once.
Comment #2
grahamcYeah, this fails equally well with only:
Textfield component
Pagebreak
File component
Save draft between pages enabled.
Add a file and click "Upload", then click Submit.
Comment #3
grahamc$form_state['values']by overly specific form validation. (#limit_validation_errors is in effect).$form_state['values'],$form['details']['sid']ends up defaulting to#value => ''.$form_state['input'], but this isn't copied to$form_state['values']because the$form['details']['sid'](from cache) already has a#valueset.Can someone wiser think of a way around this situation?
Comment #4
grahamcAttached patch targets part 4. of my description in comment #3.
It seems to make the issue as stated go away, but looks like there are similar issues with at least the uid here, possibly others.
(admin edits user's submission, uploads a file, re-submits - submission may well now belong to admin because of lost uid)
Comment #5
manimejia commentedWe are also experiencing this exact problem.
Comment #6
grahamcFor the record, I've still never actually _seen_ a problem in Webform with anything but the sid (though this kind of bug exists in several other modules)
We've been using my patch from #4 in production successfully.
Comment #7
quicksketchHi guys, thanks for your research on this issue. I'm guessing this issue continues to affect even the latest versions of Webform (4.x), because there haven't been any other major changes around this area.
I wonder if we could adjust the #limit_validation_errors property to simply include the 'details' portion of the form? But I'm not quite understanding why the file validation would be causing this problem to begin with. Like you say, this would cause problems in a lot of modules other than just Webform. Is there a core issue that you know of tracking this problem?
Comment #8
quicksketchOh! I just realized what's going on here. If that patch works, then it seems like we could just change the empty string to NULL:
This makes it nearly same thing as your patch. And 'sid' wouldn't have a value so it wouldn't get cached (I think).
Comment #9
quicksketchAssuming this is correct, this patch should fix the problem. Since it should have a minimal impact on the rest of Webform, I've committed it. Please reopen if this has not solve the problem. Committed to 7.x-3.x and 7.x-4.x branches. Thanks for the sleuthing guys!
Comment #11
szume commentedI had a same issue in 7.x-4.2. I upgraded to version 4.4, but the issue is still have.
Update:
Comment #4 patch worked for me intsead of the official(#9) solution.
Comment #12
szume commentedComment #13
danchadwick commented@szume -- Are you saying you had to patch 4.4 to get it to work? If so, can you provide detailed instructions to reproduce the issue?
Comment #14
pete80 commentedI am having the same issue with 7.x-4.10
To recreate:
Create a webforms with three pages
Add a file field to the second page
In "Form settings" select "Automatically save as draft between pages and when there are validation errors"
Fill in the form, when you press the first next page a submission is created, then upload and image on the second page, when you press next page again a new submission is created.
I have re rolled the patch from #4 against the latest dev branch, which fixes the issue for me
Comment #15
danchadwick commentedRe #14. Try the latest dev without your patch. There was an issue caused by the ajax call when you click the upload button.
Otherwise, please open a new issue.