Closed (won't fix)
Project:
Webform
Version:
7.x-3.18
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 Jan 2013 at 22:09 UTC
Updated:
6 Nov 2014 at 04:23 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
davidi commentedThis David, one of the developers who works with Aaron, the OP. Adding some info to this issue for others who might have to deal with this problem.
In 2010 Drupal core switched from using
filestable to newfile_managedtable. Also created was thefile_usagetable which appears to be a registry of which modules are using which uploaded files. Webform modules switched to this new backend scheme in early 2013 but did not provide update code in webform.install to migrate the files from old table to new or insert rows into thefile_usagetable.Webform module maps webforms to submitted files via
webform_submitted_datatable, with columndatacontaining the foreign key file id of the corresponding row infilestable. This query displays the rows in oldfilestable that belong to webforms.To see related rows in the
file_managedtable, change the 2nd INNER JOIN to reference `file_managed` table. For a database that has just been upgraded from 6.x to 7.x, this query will not return any rows.After a Drupal 6.x to 7.x migration, file mappings break due to the following reasons:
filestable have not been migrated tofile_managedwebform_submitted_data.fidcolumn still contains foreign key values for oldfilestable, which the Webform module code now interprets to be foreign key values for thefile_managedtable. Thus webforms will map to completely unrelated rows in thefile_managedtable.file_usagetable to reflect Webform module's usage of the uploaded files.Luckily the
filestable is left untouched after migration so it is possible to repair the mappings. The steps for doing so:filestable tofile_managedtable. Be aware that thefile_managed.uricolumn is defined with a unique index. During migration the values that populate this column come fromfiles.filepath, which does not have a unique index defined. In certain cases the old Webform code allowed for duplicates in this column. In our case this happened when the same user uploaded the same file on the same form more than once. These cases have to be dealt with manually.file_usagetable for each migrated row.Attached is an edited version of the ad-hoc script I wrote to do this for our site. (.txt extension is due to restriction against attaching files named *.php). I removed some stuff to preserve confidentiality but it should still work as is. Note that function
alter_duplicate_filepathswas written to be specific to our website and will not apply as a general case. Before attempting migration it should be determined if there are any duplicatefilepathvalues infilestable. If so, ad hoc transformation can be performed in this function. If no duplicates are found, invocation ofalter_duplicate_filepathscan be commented out.Links of interest
Webform module code switches from
file_managedtouricolumn is defined :http://drupalcode.org/project/webform.git/blob/cf4a11d385bcdcd18ae4f3429...
...but does not provide migration update:
http://drupalcode.org/project/webform.git/blob/cf4a11d385bcdcd18ae4f3429...
Comment #2
druderman commentedThis appeared to work well for me when I migrated 900 submissions form Webform 6 to Webform 7.x-3.19.
Thanks.
Comment #3
raveendrab commentedIt would be nice if this can be made as contributed module or get into webform update script as it will help end users (The files are not converted in 7.x-3.19 also).
Comment #4
mjwright commentedThe script worked fine for me with one exception. The filemime and filesize fields are reversed when written to the file_managed table. After running the script, the filemime field contained the file size, and the filesize field contained 0 because a string was being written to an int field.
I've attached a modified version of the script with the columns ordered properly.
Comment #5
dpfitzsi commentedJust discovered this issue today. I still need to test the script that was posted here, but something like it definitely is needed for the webform module. For all intents and purposes the upgrade path has a major failure if all of the files are mis-referenced. I tested this on a few dozen sites and I'm getting the same result posted here, completely borked submissions if they contained files.
I think this needs some more people to review this solution and if it's working as well as it does for the creator of the script then it should get committed to the webform module ASAP!
Comment #6
danchadwick commentedSeems to be a migration issue, not directly affecting webform itself. Also, Version 7.x-3.x is receiving critical bug fixes only.