Closed (duplicate)
Project:
Webform
Version:
7.x-4.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
24 Feb 2016 at 22:26 UTC
Updated:
27 May 2021 at 10:52 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
David_Rothstein commentedI can confirm this. It happens only when the user clicks "Upload" to upload their file. (If they just choose a file and then use the main form submit button, it works OK.)
I debugged this and it seems the Webform module doesn't set a #default_value for its 'managed_file' form elements correctly. (I guess maybe it never mattered before, but now, in the case of anonymous users, Drupal core is essentially relying on that to know that the file actually belongs there after an Ajax request.)
Here is a possible patch. I am not sure if it has any side effects, but it seems to work in my testing. The part of it which handles multiple file fields on the same form is kind of a hack, but without that part of the patch, if you have multiple file fields on the same webform, only the last file they upload will get saved.
I will add a note about this to https://www.drupal.org/drupal-7.43-release-notes as well.
Comment #3
David_Rothstein commentedBy the way, it's worth noting - at least in my testing, there is no feedback to the end user that their file won't be submitted. It looks to them like the upload was successful. That's one reason I marked this as major.
Comment #4
mitchalbert commentedany patch for the 7.x-3.24 version?
Comment #5
testii28 commentedYes i am looking also for a patch for 7.x-3.24 version
Comment #6
stefan.r commentedBackport to 3.x, can anyone test?
Comment #7
stefan.r commentedComment #8
stefan.r commentedRe-uploading for testbot
Comment #10
calebtr commentedPatch at #8 applies to 7.x-3.x-dev and fixes the issue.
Comment #11
awochna commentedPatch at #2 applies to 7.x-4.12 and fixes the issue for me.
Comment #12
slipperysky commentedWill patch #8 work with 7.x-3.24 or do I have upgrade it to 7.x-3.dev? When I tried the patch with 3.24, after submitting the form I got this warning:
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 175 of /home/aabbcc/subdomains/devs/public_html/includes/entity.inc)
array_flip() is in webform.module on line 3536, but that may not mean anything.
$disabled = array_flip(variable_get('webform_disabled_components', array()));Also the file URL was not in the email so it didn't work.
A while back upgraded 7.x-3.24 to 7.x.4.x but I can't remember if I had to do anything extra to make it work. Has anyone else recently moved 3.24 to 7.x.4.x without too much trouble? I might try that instead.
Comment #13
stefan.r commentedBack to NR for #12
Comment #14
stefan.r commented@slipperysky #8 ought to work with 7.x-3.24, but maybe it doesn't considering your error - do you have any way to reproduce the issue in a clean webform 3.x + drupal 7.43 install?
For instructions on upgrading to 4.x see https://www.drupal.org/node/1609324
Comment #15
criscomPatch #2 applies to 7.x-4.12 and fixes the issue also for me. Thanks for the fast patch!
Comment #16
stefan.r commentedBack to NR for #12
Comment #17
ralphmoser commentedThank you very much for the very fast reaction on this issue. I can confirm that the patch #2 perfectly solves the problem for webform 4.12.
On the other hand for webform 3.24 both patches #2 and #8 didn't work for me.
Comment #18
slipperysky commented@stefan.r - I will check if I can reproduce the same error with a clean install. Thanks for the link. I may end up upgrading to 4.x even if there's a working patch for 3.24.
Comment #19
amaisano commentedThere is a problem with patch #2, or a scenario that is incompatible with it. Files selected but not explicitly uploaded -- in other words, selecting a file, then using the main webform submit button to submit everything -- do NOT get saved if the form throws a validation error (for instance, invalid email address) and reloads the form. When the form reloads, the file HAS been uploaded and is present in the file component, but upon fixing the form error and hitting the webform submit button again, the file is NOT saved / no longer attached to the form submission.
I compared the behavior between 7.42 and 7.43 + webform patched. Can anyone else confirm?
1) Create a webform with Name (required), Email (required), and File (optional - NOT required)
2) Log out, and visit the webform anonymously
3) Enter a name, SELECT a file (but don't hit upload)
4) For email, type "name@x" and hit submit - we want to trip a validation error and have the page reload
5) Notice the file is now attached/uploaded.
6) Fix the email by typing "name@x.com" and hit the main submit button for the webform
7) Log back in and check the webform submission and review the file field - no file!
Comment #20
slipperysky commented@stefan.r - I can only reproduce half of the issue I experienced on the original form. On a clean install the warning (from #12) is not present, but the files are still not showing up in the emails so it doens't seem to be working in a clean install with 3.24. It's a simple form with 2 file uploads. The original form where I also see the warning is much larger with multiple file uploads so possibly there is something else that is helping to create the warning. Everything is working fine if I go back to Drupal 7.42.
Comment #21
santhoshabraham commentedI'm having same issue with our site. I have 2 file upload, none of the shows on e-mail or database
Comment #22
testii28 commentedI have applied the patch 4.12 and 3.24 and I am using three file fields to upload documents. but it only uploads the last file, the others not. Can that be fixed too? If that option doesn´t work both drupal site I have developed will be useless.
Thanks
Comment #23
stefan.r commented#22 I cannot reproduce, but #19 yes (and #19 we should definitely address in this patch)
Comment #24
stefan.r commentedNew 7.x-3.x patch which should fix the issue in #12
@David_Rothstein or others, both this patch (#24) and the patch in #2 still have the issue in #19 -- what would be the best way around that? Ideally we'd set the right fid even if validation fails so people don't have re-upload their file.
Comment #25
slipperysky commentedI set Webform back to 3.24 under Drupal 7.43 and used the new patch in #24.
It looks like the warning I was seeing in #12 is gone, but I'm not sure if that was meant to get fixed here.
Unfortunately it looks like I am now experiencing what happened in #22. I'm testing a form that has 5 file fields. If I only upload the first file, it will show up in the email, but if it is more than one file, only the last uploaded file will make it into the email.
Comment #26
dalanz commentedSame as #25 with 5 Fields to upload after applying #24. It only happens on new sessions. As soon as you reload the page. It works with all files. The Error I get back on uploading another file on new sessions is about a too big file (which is not the case).
Comment #27
stefan.r commentedCan anyone provide a way to reproduce the issue in #22/#24/#26 on a clean Drupal/webform install? If I create a webform with multiple file fields, with the patch it still submits both files, so I cannot reproduce this.
Comment #28
nicrodgersIs @ralph_moser actively working on this, or can it be unassigned?
Comment #29
stefan.r commentedComment #30
nicrodgersI've been trying to reproduce the error described in #22 and #26, on a clean install of 7.43 with webform-7.x-3.x.
I've been able to replicate an issue where selected files are lost, but I'm not sure if this is the same thing as described in #22. It happens with and without the patch from #24 applied. I can also replicate it using a clean install of 7.42 and webform-7.x-3.x, suggesting that it's not directly related to this issue.
1. Clean install D7.43 with webform-7.x-3.x
2. Add a webform with multiple file upload fields
3. log out and go to the webform as an anonymous user
4. open your javascript console
5. Click select file on one of the file inputs, and select a file. Don't press upload.
6. Click select file on another of the file inputs, and select a file. Don't press upload.
7. Observe the javascript errors in the console "Uncaught TypeError: Cannot read property 'length' of undefined" file.js "if (extensionPattern.length > 1 && this.value.length > 0) {"
8. Click upload next to the first file, then very quickly click upload next to the second file.
Result: First file is uploaded, but second file input reverts to the 'select file' state.
Note that you have to press the second upload button very quickly after pressing the first, otherwise you wont replicate the issue. I've tried quite a few times and can reproduce this consistently, but it all depends on you clicking the upload buttons in quick succession.
If this is how to replicate #22 and #26 then I'd suggest creating a new issue for it, and proceed with the patch from #24 (#19 still needs addressing), because neither the patch, nor the update to drupal 7.43 is responsible.
Here's a screen recording of me reproducing what I describe above:
https://www.dropbox.com/s/3dupbsxmbquut2d/webform.mov?dl=0
Comment #31
lidiia.litovko commentedI have the same issue with drupal 7.43, Webform 7.x-4.12 and Webform Ajax 7.x-1.1. Anonymous users can upload file on the server, but they can't send form after click button Send because file is missing.
Comment #32
damienmckennaTriggering the testbots for the patch in #24.
Comment #33
damienmckennaI suggest adding more tests to cover the scenario detailed in comment #19.
Comment #34
damienmckennaThe standard practice is to work on the latest branch and backport the final fix.
Comment #35
damienmckennaAs a baseline, I'm unable to reproduce the problem mentioned in #34 using Drupal 7.42 and the latest Webform 7.x-4.x using an otherwise barebones Standard site installation.
Comment #36
damienmckenna(Sorry, I just realized that the error mentioned in #30 is related to 7.x-3.x, not 7.x-4.x)
Comment #37
damienmckennaFollowing standard practices, the patch in #2 fixes the issue for the 7.x-4.x branch, so I've marked this as RTBC. Lets get this fixed first and then worry about the (deprecated) 7.x-3.x branch.
Comment #38
stefan.r commentedSo #19 was a separate issue and was also broken before 7.42?
Also #22/#31 mentioned some issues with the 4.x patch, those have been addressed?
Comment #39
damienmckennaGiven the simpletest limitations with Javascript, is this even testable?
Comment #40
damienmckennaI've re-tested it and yes, triggering a validation error does still trigger the error.
Steps to reproduce:
Comment #41
slipperysky commentedWanted to add a little more info based on #25. I had went directly to the original site to test the newest patch in #24 and got those results in #25. Soon after that I was able to test a clean install (7.43/3.24) with 2 file fields and I couldn't reproduce it.
But at the same time, there are at least a couple people commenting here who seem to be having the exact problem that I'm having with an "unclean" install, where only the last file field makes it into the email.
Edit: Never mind the PDO exception below. I found out that the database was somehow getting out of sync with the actual files uploaded to the server so that's probably what caused the error.
Plus, something new started happening. I went back to test the original site again and realized that I hadn't cleared the cache, so I did that and then I started getting an AJAX PDOException for trying to upload a duplicate file.
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entryThis error only seems to happen on the file fields after the first one. I can successfully upload a duplicate file that gets renamed on the first field, but after that the other file fields will give the error.
Maybe it's the setup in this particular form, but I'll keep testing to make sure this is what's really happening.
EDIT: I tested uploading each file field in random order and started getting random results. Sometimes the PDO error was triggered, sometimes not. It also started getting triggered by the first file field so that was wrong. I've never seen this error before in Drupal so I'm not sure what to think of it. Sorry if it's going off in a direction that's not related to the reproducible issues.
Comment #42
damienmckennaI'm working on some tests for the file handling; these aren't finished yet but I wanted to upload something.
Comment #44
damienmckennaBTW the test in #42 depends upon #2678026: Tidy up the tests a little.
Comment #45
damienmckennaI've expanded the tests to cover actual file uploading.
Comment #47
damienmckennaThis adds tests to confirm file uploads still work when a required text field is initially left empty but then submitted again.
Comment #49
damienmckennaThis tests multiple file uploads, and here's the output so you don't think I'm crazy ;-)
Comment #51
damienmckennaThis patch includes the changes from 2678026, just so you can see how the tests work.
Comment #52
damienmckennaSo... the tests pass, even though I haven't changed the code *and* it tests the scenario that fails in manual testing. Is this a limitation of the tests or Simpletest?
Comment #53
stefan.r commentedCritical because of data loss of submitted uploads (without any error message indicating so)
Comment #54
therobyouknow commentedI have three questions, if you could advise please:
1) Looking at: https://www.drupal.org/node/2675170 Can you advise which patch should be used:
OR
Are they identical in terms of fix (but #51 contains test code?)
2) Is this correct: These patches will fix the issue in webform 3 if they are applied to the latest version of Webform 3, i.e. 3.24 (as of 2016-03-01) ?
3) When applying the patch, can the following command be used:
patch -p1 < webform-n2675170-49.patchwhen cd into in the webform module folder sites/all/modules/contrib/webform/ ? Or would you recommend another approach to apply the patch?
Thank you very much for providing the fix.
Comment #55
damienmckenna@therobyouknow: 1) Neither #49 nor #51 are for Webform 7.x-3.x, they're for the 7.x-4.x branch. 2) No, you need patch #24 for 7.x-3.x but that still has problems. 3) You can skip having to manually download the file using this command:
curl URLTOTHEPATCH | patch -p1That skips downloading the file.Comment #56
therobyouknow commentedThank you very much @DamienMcKenna for following up with the information and so soon too, most appreciated.
From #19 it would appear then that this issue is that an uploaded file associated with a webform submission becomes orphaned after re-submitting a form following correcting other invalid fields, have I understood correctly?
Just to confirm #24 is only for 3.24 (latest, currently) is that right? (You mentioned 3.x, so I'm assuming it is the latest version, or is it for 3.x-dev?)
Thanks very much again for all your input.
Comment #57
therobyouknow commentedAnswering my last question:
Yes - #24 indeed IS for webform-7.x-3.24 (the latest version of webform 3 currently).
I know this because the patching works and I inspected it in diff and Beyond Compare (before and after) comparing the diffs shown on these tools with the patch itself. The curl command works perfectly - thank you so much!
I'll test the solution.
I'm inclined to go with what we have here and perhaps add a markup in the form to warn users that they need to re-upload their files if they had invalid fields elsewhere. But I will watch the developments on this issue with interest as well and of course any help I can give I would try to. Thanks!
Comment #58
damienmckennaThe fun part of patch #51? The testAnonFileRequiredSubmission test should fail, but it doesn't. Not sure if this is a limitation of the tests, of Simpletest, or the module itself.
Comment #59
santhoshabraham commentedHi,
I applied patch #24 IS for webform-7.x-3.2, and still having issue uploading multiple file for anonymous user. It works fine if you log in.
Here is the steps you can duplicate.
This is for version 7.x-3.24
1. Install D7.43 with webform-7.x-3.24
2. Add a webform with multiple file upload fields and make it REQURED field.
3. log out and go to the webform as an anonymous user
4. Upload files to both field
5. Click submit.
Now you going to see only one file upload and one file field with error message.
Comment #60
David_Rothstein commentedRegarding #19, nice find, but I'm able to reproduce that with Drupal core also, so it's probably not something for Webform to fix. I created an issue about it in the Drupal core queue now.
Comment #61
webservant316 commented#50 works for me, though I manually applied the patch to webform.module and file.inc without the patches to the tests. #49 and #50 are identical except for differences in the patches to the tests. I wasn't sure which was recommended so I just patched what was needed for the fix.
Thanks for these patches!
Comment #62
David_Rothstein commentedMaybe try changing fileRequiredSubmissionTest() so that the second submission at the end, i.e. this part:
does a drupalPost() to NULL rather than to
'node/' . $nid, $edit? (That way it will submit the existing form again rather than do a GET request in between to reload the form.)Comment #63
damienmckennaThis changes the fileRequiredSubmissionTest() to resubmit the current page instead of submitting to the specific URL again, per David_Rothstein's suggestion. Also, duh Damien :p
Comment #65
amaisano commentedThank you, David, for confirming and discovering the source of #19!
Comment #66
cjallenD1 commentedThanks David! I applied these patches and at first tests all seems well. I am using Webform 4.12
I have two file uploads for an application and these two files accept doc/pdf.
I have combined the patch from #2 in combination with the AutoUpload module and it seems to be operational.
I'll continue to test and post updates.
Comment #67
cjallenD1 commentedI get the following now when uploading multiple files with the patch in #63
An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (20 MB) that this server supports.The file in question is well below 20mb (22kb).
Comment #68
damienmckennaI've uploaded a patch to #2678822: Drupal 7.43 / 8.0.4 regression: When an anonymous user submits a form with an un-uploaded file that leads to a validation error, the file is lost on the next correct submission that shows the error occurs with a standard node submission by an anonymous visitor, like David Rothstein indicated.
Comment #69
damienmckenna@cjallenD1: That's.... really weird. Is the problem consistent? Is it reproducible across multiple webforms, or just one?
Comment #70
damienmckennaThis is blocked by core: #2678822: Drupal 7.43 / 8.0.4 regression: When an anonymous user submits a form with an un-uploaded file that leads to a validation error, the file is lost on the next correct submission
Comment #71
damienmckennaLeaving this for someone else for now, need to do some other things for a while.
Comment #72
cjallenD1 commentedDamienMcKenna - I just ran a few more tests and believe that 'Unrecoverable error .. file size ..' error was due to the combination of the patch + the module AutoSubmit.
Upon disabling AutoSubmit and hiding the upload button on my webform via CSS the uploads work properly.
-chris
Comment #73
galactus86 commentedGlad to see this issue is being looked at. I am using version 7.x-3.24. When anonymous user submits a webform with upload the file goes to the server. But when I check the results page, the link to the resume is not there. This seems similar to what this issue is discussing. Does patch #24 work?
Comment #74
beezer75 commentedSame issue here. The files seem to upload fine for unauthenticated users who bypass clicking upload and go straight to submitting the form. They disappear if the user clicks upload. The functionality is fine for authenticated users.
Comment #75
webservant316 commentedI posted above in #61 saying that the patches in #49 and #50 work for me with Drupal 7.43 and Webform 7.x-4.12. I manually applied the patch and skipped the part of the patch dealing with regression testing.
Anyway I am trying to follow the post discussion to understand if all is well with the patches in #49 and #50. I was concerned and so did further testing and in my use case everything still works fine when an anonymous user uses the file upload button or simply clicks the submit button only at the bottom of the form. My use case only allows the upload of one file.
Just reporting back.
Comment #76
damienmckenna@webservant316: Have you tested what happens if the visitor triggers a validation error, e.g. fails to fill in a required field? In that scenario a bug in core will loose the file.
Comment #77
webservant316 commentedok - just tested that.
So as an anonymous user I used webform to upload a single file using the form submit button with a validation error, corrected the error, submitted and the file was there just fine. I then did it again using the upload button, submitted with a validation error, fixed the error, submitted and again the file was there just fine.
I am using Drupal 7.43 and Webform 7.x-4.12 with the patch from #49 and #50 manually applied without the regression testing part of the patch.
Comment #78
cjallenD1 commentedDamien, webservant316 -
In my use case with Webform 4.12 and patch from #2 I believe, I do get the validation error with invalid email (mail@mail).
When doing this the files show to be there. However, upon submission they get wiped out.
Again, this was from an earlier patch (i think from #2).
If webservant316 does not get that 'validation error/file removal' error with #49 + #50 I will try those patches and report back.
Comment #79
webservant316 commented@cjallenD1 keep in mind that patch #49 and #50 are the same with regard to the actual fix, however they each propose different regression testing. Since I didn't know which was better I manually applied pieces of the patch only to webform.module and file.inc.
Comment #80
cjallenD1 commented@webservant316 - Oh I see. I did the same; applied only patches to webform.module and file.inc (ignoring tests).
Strange that my files do get wiped out after validation.
Comment #81
webservant316 commentedhmmm strange. I tested further submitting a webform that returned a validation error without a file attached and then attached a file before the final submit, both with and without using the upload button and that worked for me as well.
I wonder what the difference is? Does the type of validation error matter? I was just leaving a required field blank.
Now my file field is not required. Is that the difference?
Comment #82
amaisano commentedFor me, it was not putting a domain extension on an email field (person@place instead of person@place.com).
Comment #83
cjallenD1 commented@webservant316 - possibly. Both my file upload fields are marked (and need to be) required.
I'll test on my sandbox on required/unrequired fields
Comment #84
calebtr commentedI notice that using Mollom to validate webform submissions is breaking file upload. My sense is that this is just related to the validation issue in core and the workaround for now is to disable Mollom.
Any other modules that provide additional form validation for anonymous users could cause the same problem.
Comment #85
webservant316 commented@amaisano
A attached a file with upload, entered bad email, submitted, validation failed, fixed email, re-submitted.
Everything was fine.
Comment #86
dherbold commentedBeen following this.
With patch 49/50 applied, probs still exist.
Clearing browser cache, upload of subsequent files (after 1st file), fails.
Reload page. Do NOT clear cache. Upload of multiple files succeeds.
Clear cache again. Reload page. Upload subsequent files (after 1st file), fails.
Comment #87
David_Rothstein commentedI just posted a core patch at #2678822-13: Drupal 7.43 / 8.0.4 regression: When an anonymous user submits a form with an un-uploaded file that leads to a validation error, the file is lost on the next correct submission that needs testing and may fix all this on its own. (Not just the part that was the core bug, but it may fix the Webform-specific parts also.) So it would definitely be good to test that with Webform.
Making Webform set #default_value correctly (as the patches here try to do) is still a good idea anyway (and of course the tests are a very good idea), but if this regression can be addressed in core then it becomes a lower-priority issue for Webform to have to deal with on its own.
Comment #88
jdflorez commentedTested #87.
Attached two files without, entered bad email, submitted, validation failed, submitted again, validation failed, validated email, re-submitted & the files were uploaded.
Previously, if a validation failed after the files were uploaded, in the next reload the uploaded files were lost.
Comment #89
srutland commentedApplied #49 with the testing code and solves the upload problem for anonymous users. Applied it to our profile which is D7.43 and Webforms 7.x-4.10.
Uploaded an Excel file of our testing results. Let me know if we missed anything.
Also validated the error indicated by David_Rothstein in #87. Will be applying that patch later today.
Found a different problem (for a different issue tix) when multiple file upload fields are used. If a user clicks the upload buttons too fast: the second, fourth, and so on fields clear out and the files don't upload. Validated this is the case with D7.42 as well. Again, this isn't a problem with the current issue.
Thanks to all for the quick response on this issue.
Comment #90
izmeez commented@srutland did you see the comment #2678822-17: Drupal 7.43 / 8.0.4 regression: When an anonymous user submits a form with an un-uploaded file that leads to a validation error, the file is lost on the next correct submission
Is your situation different?
Comment #91
damienmckennaI tested out the latest patch from #2678822: Drupal 7.43 / 8.0.4 regression: When an anonymous user submits a form with an un-uploaded file that leads to a validation error, the file is lost on the next correct submission and it seems to solve the problem.
This patch fixes one item in the tests and they now all pass correctly when that patch is applied to core.
Comment #92
damienmckennaFYI all tests pass even without the changes to components/file.inc or webform.module:
Comment #93
damienmckennaCan others please try out the patch in #2678822: Drupal 7.43 / 8.0.4 regression: When an anonymous user submits a form with an un-uploaded file that leads to a validation error, the file is lost on the next correct submission and let us know if the problems persist on either 7.x-4.x or 7.x-3.x? Thanks.
Comment #95
slipperysky commentedI upgraded Webform 7.x3.24 to 7.x4.12. Then I tried applying anonymous-file-upload-2678822-13.patch to Drupal and applied the patch in #49 (without the tests). I submitted the form with 3 file uploads with no problem. All the file links showed up in the email. I tried it again triggering validation with no problems. Was there another issue I missed?
So far for me it looks like all the original issues have been fixed.
Comment #96
srutland commented@izmeez, continuing from #89 above we have now patched with #2678822: Drupal 7.43 regression: When an anonymous user submits a form with an un-uploaded file that leads to a validation error, the file is lost on the next correct submission and it's working correctly. Files are attached to the webform result after anonymous user corrects validation (email field) and re-submits.
Our enviro D7.43 and Webform 7.x-4.10
To summarize:
- the patch for this current issue (2675170) fixes the upload problem for anonymous users
- the patch at 2678822 #87 solves that issue for us (will make an entry on that issue)
Comment #97
slipperysky commented#93 - Also tested a clean install of Drupal 7.43, Webform 7.x3.24, applied the patches to both of them and didn't see any of the problems.
Comment #98
nicrodgers@srutland I've just created a separate issue for the 'fast clicking' bug described in #30 and #89 here: https://www.drupal.org/node/2681011 as (like you say) it's unrelated to the current issue.
Comment #99
smbenoit commentedI'm a total Drupal newb, as well as a newb to development/coding. I'm sure this a ridiculously dumb question,
How do I install the provided patch to Webform?
I see the code, but what do I do with it? Does it go in the components folder of Webform? What should the file extension of the text document be called? Do I paste it into the "file.inc" document in the components folder?
I'm about to delete Drupal off of my server, install 7.42, and build the entire website over again from scratch all due to this one problem. I'm hoping someone can give a solution before I do that.
Thank you.
Comment #100
damienmckenna@smbenoit: No need to do that. Use patch #22 from #2678822: Drupal 7.43 / 8.0.4 regression: When an anonymous user submits a form with an un-uploaded file that leads to a validation error, the file is lost on the next correct submission and see https://www.drupal.org/patch/apply for instructions on how to apply it to your Drupal install.
Comment #101
nicxvan commentedI am using the patch mentioned in #100 as well as #24 here as I am on 3.x
I found the upload issue to still be intermittent, it seems to be related to required fields. If all required fields are filled out before uploading it works. I ended up just marking all fields as optional temporarily for this particular customer and it seems to be working.
Comment #102
squarecandy commented#49 works for me.
I also applied #22 from here: https://www.drupal.org/node/2678822
Is that what I'm supposed to do? Just the patch from this thread seemed to solve it. A bit confusing with all the co-mingled related-but-different issues.
Thanks!
Comment #103
dcamburn commentedDo we have an official answer on how this is going to be fixed? Whether Drupal Core will be updated to fix it, or whether Webform will be updated to fix it?
Comment #104
damienmckenna@dcamburn: We're waiting for a core committer to respond to the issue :-\
Comment #105
gaurav_manerkar commentedPlease apply this patch works for me
Comment #106
gaurav_manerkar commentedMy patch works fine, tested by me
Comment #108
damienmckennaMarking this 'postponed' until the core issue is resolved.
Comment #109
bukhnerav commented#105 works for me. Thanks!
Comment #110
jweowu commentedDamienMcKenna: webform-file-upload-for-anonymous-user-2675170-2.patch contains a syntax error.
PHP Parse error: syntax error, unexpected '}' in sites/all/modules/contrib/webform/webform.module on line 2727
Comment #111
damienmckenna@jweowu: Please don't use that patch, use the one from #2678822: Drupal 7.43 / 8.0.4 regression: When an anonymous user submits a form with an un-uploaded file that leads to a validation error, the file is lost on the next correct submission instead.
Comment #112
jweowu commentedIndeed, I've noted that #22 from that issue resolves the problem. (Thanks!) It was a bit confusing as #108 in this issue post-dates that, and so my initial impression had been that both patches were necessary to resolve the issue for webform components.
Comment #113
David_Rothstein commentedI committed #2678822: Drupal 7.43 / 8.0.4 regression: When an anonymous user submits a form with an un-uploaded file that leads to a validation error, the file is lost on the next correct submission to Drupal 7, so reopening this. Not sure what the right next step is here now - get the tests committed via this issue, and move the #default_value improvements (at least the ones not labeled "hacks") to a separate issue so they can be evaluated on their own merits, even if no longer needed to fix this bug?
Comment #114
David_Rothstein commentedRegarding #67 from @cjallenD1:
That actually sounds a lot like a different (and older) Drupal core bug: #2392117: Forms with multiple file form elements produce upload errors with the Drupal page cache enabled. Perhaps that's the root cause (although a different solution was reported in #72)?
Comment #116
torgospizzaI just wanted to say that applying the patch from #2678822-22: Drupal 7.43 / 8.0.4 regression: When an anonymous user submits a form with an un-uploaded file that leads to a validation error, the file is lost on the next correct submission also seems to have solved the issue for me. Before, I could consistently get the error to appear by always doing the following steps in Webform:
1. Browse and choose a file to upload to a File field;
2. Click "Upload" and let the file upload.
3. Click "Submit" to submit the form.
9 Times out of 10, Upload -> Submit would fail in a "File field is required" error, but now with that patch applied, the error no longer occurs.
My hunch is that this means this issue and its patch is no longer needed, but I could be wrong.
Thanks for the fix!
Comment #117
glassfrog commentedAny word on when this fix will be released in core/webform?
I'm running Drupal 7.43 with webform 7.x-4.12 and I cannot figure out what's happening with all the comments on 7.x/6.x.
Comment #120
liam morlandThe fix has been committed to core. If you run revision 6b6bc1b, you will get the fix. That is just two commits past 7.43.
Comment #121
torgospizza@glassfrog: Did you try the patch from the other issue? Patch from #22 in #2678822-22: Drupal 7.43 / 8.0.4 regression: When an anonymous user submits a form with an un-uploaded file that leads to a validation error, the file is lost on the next correct submission fixed the issue for me.
Comment #122
liam morlandThe patch from #22 is what got committed to D7 in 6b6bc1b. If you are deploying with Git, just checkout 6b6bc1b and you're done.
Comment #123
dsoini commentedI have Drupal 7.43 and webform 7.x-3.24 and I have the problem with file upload fields as mentioned. Additionally, I have the problem that if someone submits the form with missing required fields there is no error message and the form does not submit. It just returns to the form.
If I install the patch (2675170-24.patch), a form submission with missing fields (of any kind) still fails to show an error message. It does fix the file upload issue, but it doesn't solve the issue of no error messages.
Comment #124
Anonymous (not verified) commentedHi all we just applied the patch. I have multiple file uploads on the same form.
Files are uploaded but do not show up on the results page.
Comment #125
criscomWe had the same problem as in #19. We solved the problem, patching Drupal core by applying 6b6bc1b as mentioned in #22
Comment #126
priyapr commentedHi crisom,
Could you please confirm whether it solved for webform 7.x-3.24 or webform 7.x-4.12. I applied the patch #22 on Drupal core 7.43 and webform 7.x-3.24, but still it is not get solved the issue reported in #19.
Thanks
Comment #127
priyapr commentedWebforms with Mollom or old version google recaptcha (manually enter number or text) or any other modules that provide additional form validation for anonymous users cause the same problem reported in #19 for webform 7.x-3.24 and webform 7.x-4.12. In the above mentioned cases, the page reloading with validation error and uploaded file lost that cause the issue.
Thanks
Comment #128
labboy0276 commentedJust to ease the confusion, people are mentioning #22, but it is in this issue: https://www.drupal.org/node/2678822#comment-10926613 not this issue.
Comment #129
lu_smithcon commentedI'm using Drupal 7.43 and Webform 4.12 and the webform file fields are private. Private Files Download Permissions handles the permissions. I applied drupal-n2678822-22.patch two days ago. I cleared the cache and tested the webform as an anonymous user and it worked as it should. Today the file upload isn't working properly once again. The files are uploaded to the server but are not visible in the webform results (again). In the files_managed table in the db the status of the uploaded files are 0 (temporary) whereas the file from my test submission 2 days ago is 1 (permanent). I have not changed anything since I applied drupal-n2678822-22.patch. Anyone have a clue what is wrong?
Comment #130
erier commented#105 also worked successfully for me. Patch applied to Webform 7.x-4.12
Comment #131
criscompriyapr, sorry just saw your comment: we fixed webform 7.x-4.12 with the patch.
Comment #132
drupalevangelist commented#2 Worked for me. Thanks David
Comment #133
ludo.rI also have a PHP syntax error when applying patch #105 (https://www.drupal.org/node/2675170#comment-11004815) to Webform 4.12
Comment #134
jweowu commenteddolu: https://www.drupal.org/node/2675170#comment-11034991
Comment #135
damien___b commentedWe have multiple mail systems.
Attachment through mimemail mail system is working now thanks to #2.
Thanks David.
Comment #136
knalstaaf commentedI'm using two upload fields and the patch of #49 isn't doing it for me.
Provided a workaround by hiding the file submit buttons of the upload fields with CSS, so the user can't actively use them. As long as none of the file submit buttons are being used, there doesn't seem to a problem.
Comment #137
criscomIt seems drupal-7.44 has re-introduced the error/bug again.
Comment #138
criscomLooks like the commit in #2 didn't make it
fullyinto file.module at all. (https://www.evernote.com/l/ARCteKjTztVN17bl3vLmQ9qpgP4iZoB2vzE)Below part is missing in the 7.44 version of file.module
Comment #139
scrypter commentedThanks criscom for confirming this. I was transported back to when 7.43 was released and had to revert. What needs to happen to get this patch into core so that when 7.45 comes out we don't have all this drama again?
Comment #140
damienmckennaJust to be clear, the fix is not in 7.44 because that only contained security fixes, no other changes were included. The fix is currently slated for the forthcoming 7.50 release, per David_Rothstein's comment in #62 of the other issue.
Comment #141
hmartens commentedI can confirm that with Drupal 7.44 it still didn't work. I had to use Patch #2 and then it worked. Thanks guys for the awesome work!
I appreciate all your hard work!
Comment #142
danica101 commentedworked for me.
thanks
Comment #143
sic commentedThe 3 branch patch still does not work properly.
Steps to reproduce:
Two fields Foo and Bar, both required.
Browse/select a file for Foo, submit the form. Errors appears "Bar" is required. Upload a file for Bar, submit the form. Error: Foo is required.
Comment #144
stefan.r commentedThat's incorrect as explained in #140.
Shouldn't this issue be a won't fix, since it will be fixed in core as of the upcoming 7.50 release (planned for next month)?
In the mean time, people should use the core patch (https://www.drupal.org/files/issues/drupal-n2678822-22.patch) rather than any patch in this issue
Comment #145
webservant316 commentedIs this patch still needed with drupal 7.50? Which patch above?I see the core patch is included with drupal 7.50. Sorry about that.
Comment #148
crutch commentedJust completed upgrades and testing using core 7.50. Webform 7.x-4.13 and webform 7.x-4.5 were both tested with anonymous user. They both work fine and able to access the documents in results tables. Captcha module has an issue, re: https://www.drupal.org/node/918856#comment-11526361
Comment #149
damienmckennaChanging to "duplicate" rather than "won't fix" as the primary issue was in core, not Webform.
Other problems should be handled via separate issues.
Comment #150
roychan commentedHere is how we fix the problem without patching. To accept anonymous uploads where Drupal doesn't if file was uploaded in the same session.
Instead of patching the webform module, we inject an extra process to the managed file type as a temp fix, to make sure both $form_state['input'] & $form_state['value'] comes with the same fid as we can also found in the session.
Comment #151
gaurishankarpatch #2 works for me (version: 7.x-4.12)
Thanks!
Comment #152
melsi commentedUpdated patch for 7.x-4.16.
Comment #153
caspervoogt commentedPatch #152 worked for me on 7.x-4.17, though it had trouble locating the files to patch (I had to manually specify the file path for each file it wanted to patch).
Comment #154
caspervoogt commentedI have just had a recurrence of this issue using 7.x-4.19 (unpatched) and core version 7.63. I then applied patch #152, and that solved it. Maybe this patch should be tested by a few others. I understand core applied some relevant changes in 7.50, but somehow something appears to have changed between 7.50 and 7.63.
Comment #155
damien_bates commentedI've just had a recurrence of this issue as well using webform 7.x-4-20 and core version 7.67. Like caspervoogt, I applied patch #152 and the problem was resolved. Had the same issue, the file was using a private file directory and worked when just the submit button was used by an anonymous user. However, once the user used the upload button below the field an error indicating the file was required would continue to be thrown.
Comment #156
liam morlandAre there steps to reproduce the problem on a clean install? The patch needs to be rolled against the current development version.
Comment #157
spokjeReroll of 7.x-3.x patch in #24 against latest HEAD of the 7.x-3.x branch.
Comment #158
den tweed commentedReroll for 7.x-4.23