Closed (fixed)
Project:
Webform
Version:
7.x-4.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
10 Oct 2011 at 19:07 UTC
Updated:
9 Aug 2012 at 04:11 UTC
Jump to comment: Most recent file
Comments
Comment #1
quicksketchI can't confirm this problem on either Drupal 6 or Drupal 7. Both properly delete a file when the submission is deleted. Do you have any other webform-related modules installed?
This is the code that does the deletion, looks like it's working properly:
Comment #2
quicksketchComment #3
meerkat commentedI've got the same problem in 7.x-3.15.
The delete file function below definitely being called when the submission is deleted:
However, file_delete() uses file_usage_list() to check if the file is in use, if it is then an array is returned and the file is not deleted.
In my test case file_delete() is returning
and the file is not deleted.
If my observation is correct I think there two solutions - bludgeon file_delete() into deleting the file by using the $force parameter or get webform to release the file before calling file delete.
btw, I'm very much liking the Ajax file upload in the latest dev version.
Comment #4
overtune commentedIt's the same problem with 7.x-4.0-alpha2.
Uploaded files doesnt gets deleted when deleting the submission. I have tested both with public and private files.
(The files arent used anywhere else then in just that submission).
Comment #5
quicksketchThanks guys, I think you're correct. Ever since we switched to using the managed_file element we haven't been removing records from the file_usage table, and therefor files aren't getting deleted. :(
Fortunately we can clean up our records with an update hook and clean up all the ones that have been lingering.
Comment #6
liam morlandThe attached patch adds a call to file_usage_delete() so that uploaded files get deleted when their submission is deleted or results are cleared. This does not clean-up files left over from submissions already deleted.
Comment #7
liam morlandThe attached patch creates an update hook to clean up files left over from submissions that have been deleted. This patch must be applied along with the patch in #6.
Comment #8
quicksketchThanks Liam! This patch needs to be applied to 3.x also, so I applied this backport also. Committed.