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.
Comment | File | Size | Author |
---|---|---|---|
#2 | CORE__temp-file-warning.2897165-2.patch | 934 bytes | AdamPS |
Comments
Comment #2
AdamPS CreditAttribution: AdamPS at AlbanyWeb commentedComment #3
AdamPS CreditAttribution: AdamPS at AlbanyWeb commentedComment #4
cilefen CreditAttribution: cilefen commentedComment #6
lslinnet CreditAttribution: lslinnet at FFW commentedThis seems to relate or be a duplicate of https://www.drupal.org/node/2802803
Comment #7
cilefen CreditAttribution: cilefen commentedI agree. Please let's shift efforts there.
Comment #8
ret5 CreditAttribution: ret5 commentedYeah 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.
Comment #9
boliston CreditAttribution: boliston as a volunteer commentedthanks for the useful hint to delete the items using phpmyadmin so they dont keep showing in cron logs
Comment #10
handkerchiefI had the same problem, #9 works as a workaround.
Comment #11
karthikeyan-manivasagam CreditAttribution: karthikeyan-manivasagam as a volunteer commentedSmall workaround for this issue as start off with. skip temp file warnings, I'm using the external storage it works for me.
Comment #12
erykolryko CreditAttribution: erykolryko commentedfor drupal 7 i did this DELETE * FROM `file_managed` WHERE `status` = 0