I'm seeing an issue with content types that contain two cck filefields using the Multiupload Filefield Widget. I've installed a clean version of Drupal 7, with only the Multiupload Filefield Widget enable.
Here is the behavior:
1) Create a content type with two filefields using the Multiupload Filefield Widget.
2) Create a node.
3) Upload several files to the first file field.
4) Upload several files to the second file field.
5) Save the node.
Result - First field contains just one image, Second field contains all images. After deleting the node, the missing images are stranded in the file_managed table in the database.
If you upload to just one file field at a time (between saves), it behaves as expected.
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | multiupload_filefield_widget-only_one_image_is_saved_to_first_field-1432968-18.patch | 3.86 KB | robertom |
Comments
Comment #1
czigor commentedCan you confirm that with the second attempt all the files get uploaded? That is:
1. Upload some files
2. Save (only one file appears)
3. Edit node
4. Upload the missing files again
5. Save
How many files do you see now?
Comment #2
harris_david commentedI can confirm that the second attempt works. However, I believe this is not because of the second attempt, but because only one field is being adjusted. I can save to any one of the fields at a time . . . just not both.
Also, after following your steps, I see that the files that were "missed" on the first attempt get stranded in the filesystem and in the database ( file_managed table ).
I also noticed this behavior:
1) upload 5 files to each field and save.
result - 1 file in the first field, 5 in the second.
2) re-upload the 4 missing files to the first field, but add a new file to the second field.
result - 2 files in the first field, and 6 in the second.
It appears that if you make any changes to the second field, it will only add 1 file to the first field.
Comment #3
rockaholiciam commentedI can also confirm this. I only have one image field in my content type and the first attempt only registers one image file, even though the others get uploaded. Its only on the second attempt at uploading that the rest show up.
Comment #4
rockaholiciam commentedOn some testing, I discovered that the bug can only be reproduced if you add another field in one of the multifields(any field with multiple values) on the form. If you dont, the files get uploaded fine. Its only on adding another item that only one file gets saved, however they all get uploaded.
Comment #5
czigor commentedThis seems to be very similar:
http://drupal.org/node/1112966
It is fixed for D8, but it needs a backport to D7.
Comment #6
rockaholiciam commentedhei, thanks for the reply...its similar but not the same I believe...is it possible for you to point me to the chunk of code/method which sets the file as permanent and moves it to file usage after all is said and done? I found one file status field in code but changing it to 1 resulted in more errors for that validates the fields like title and alt text on upload...thanks
Comment #7
rockaholiciam commentedOn further digging, I realized file_usage hasnt got much to do with it...the prob is that except for the default image, or 'delta 0', the others never make it to the field_images table...I believe at some point, the form_state gets overwritten and except for the default value, others are lost.
Comment #8
rockaholiciam commentedComment #9
rockaholiciam commentedSo here is my quick fix for the issue. I noticed that this method is being executed every time another field was being added to the form which I believe shouldn't be the case...one can also wrap some of the code above under a similar check that verifies if the field is indeed the one related to file for I see no point in all that code being executed if I add another text field for instance. I stripped it for simplicitys sake and only added this chunk before the $elements is returned in the multiupload_filefield_widget.field.inc file:
Hope it helps. Thanks.
Comment #10
dhalbert commentedI have a similar problem in the following situation:
I have a content type with two image fields (no field groups):
1. holds a single image (required field)
2. holds unlimited images (not required)
If I multi-upload a bunch of images to field 2, and then a single image to field 1, and then save the node, only one image gets saved to field 2. I can then go back and re-upload multiple images to field 2, and save, and they all get saved (with new names, and the original uploads are still in the target directory).
I also tried this on a fresh Drupal 7 installation without multiupload, uploading the files one at a time, and the problem does not occur. So it is not the core bug #1112966: Cannot upload file when having two file fields mentioned above, which is supposed to be fixed, anyway.
Comment #11
dhalbert commentedHi - where is the patch in #9 supposed to go?
Comment #12
czigor commentedChanging the title
Comment #13
rockaholiciam commentedRefer to number #8. #9 only mentions the bit that was added to the method.
Comment #14
joeysantiago commentedAdd #9 code to multiupload_filefield_widget.field.inc, line 120 (version 7.x-1.0+4-dev).
Works perfectly.
Comment #15
Neltharian commentedNot working - showing from 2 to 1 images (((
Comment #16
cweagansComment #17
Taxoman commented#5: For reference - fixed in core also for D7:
#1059268: Files are lost when adding multiple files to multiple file fields at the same time
Comment #18
robertom commentedHi, sorry for my bad English
Bug #1059268: Files are lost when adding multiple files to multiple file fields at the same time is fixed (commit), but multiupload filefield widget module uses old code of file.field.inc
I would add a proposed patch
Comment #19
czigor commented