In #289919: Provide AJAX-based file uploads/Progress Bar for uploads, we revamped the file handling so that the file component used the new "managed_file" upload element, allowing for AJAX-uploading. While we properly add file_usage entries to keep track of which files are associated with submissions, we *never mark the file permanent* in the file_managed table. Surprisingly this doesn't cause any terrible harm, but it's not correct. I would have assumed that a file marked temporary would be deleted by system_cron() on cron jobs, but much to my surprise, it doesn't delete files if there are any usages reported. Since a usage exists but the file is temporary, the only bad thing that happens is an entry gets logged in watchdog:

From system_cron():

watchdog('file system', 'Did not delete temporary file "%path" during garbage collection, because it is in use by the following modules: %modules.', array('%path' => $file->uri, '%modules' => implode(', ', array_keys($references))), WATCHDOG_INFO);

So that's a good thing, we can easily fix this through an update hook and no ones files were lost. We don't even allow access to files any more if they're temporary unless users have a matching cookie, so we're safe on all counts here. I'm still marking this major because it's a data-corruption issue. Even though core doesn't do anything dangerous, the expectation is that a temporary file can be deleted, so we need to fix this as soon as possible.

#1 webform_file_permanent.patch1.01 KBquicksketch
Members fund testing for the Drupal project. Drupal Association Learn more


quicksketch’s picture

Status: Active » Needs review
1.01 KB

A simple patch to fix this problem. I don't think a batch update is necessary, since we can do this all in one query.

quicksketch’s picture

Status: Needs review » Fixed

Committed to 7.x-3.x branch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.