Drupal deletes unused temporary managed files automatically in file_cron. However if the file has already been deleted from disk, then Drupal generates an error message:

Could not delete temporary file "public://XXXXX" during garbage collection

The error message repeats every cron cycle and there is no obvious way to recover from the UI.

It seems that this error message is unnecessary and unhelpful. If the file is missing, Drupal can just delete the managed record for it, and then the site is in a consistent state.

It's true, users shouldn't manually delete the file, but it can happen:

  • Novice users who don't understand managed files.
  • Someone is in a hurry and cuts a corner.
  • The file contains confidential information that should never have been published and must be deleted immediately.
  • Someone uploads a subtly but importantly different variation of a file and wants to ensure no one uses the old version by mistake.

At the moment it seems that Drupal is acting like a scolding school teacher "now you shouldn't have deleted that file, so everybody is going to punished until you put it back". Instead let's make Drupal helpful to novices and everyone else and recover automatically.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

AdamPS created an issue. See original summary.

AdamPS’s picture

Status: Active » Needs review
FileSize
934 bytes
AdamPS’s picture

Issue summary: View changes
cilefen’s picture

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

lslinnet’s picture

cilefen’s picture

Status: Needs review » Closed (duplicate)

I agree. Please let's shift efforts there.

ret5’s picture

Yeah I cut a corner and got slapped with this persistent error. Sigh.

So until a patch is committed to core, I did the following easy solution:

Installed and visited phpMyadmin and removed the offending files in the file_managed table (the offending file entries are marked with a status of "0").

Delete these, Flush Cache, and Run Cron again.

boliston’s picture

thanks for the useful hint to delete the items using phpmyadmin so they dont keep showing in cron logs

handkerchief’s picture

I had the same problem, #9 works as a workaround.

karthikeyan-manivasagam’s picture

Small workaround for this issue as start off with. skip temp file warnings, I'm using the external storage it works for me.

erykolryko’s picture

for drupal 7 i did this DELETE * FROM `file_managed` WHERE `status` = 0