Custom Thumbnail Files Disappear After a Few Hours
Eric At NRD - October 15, 2009 - 17:38
| Project: | Embedded Media Field |
| Version: | 6.x-1.11 |
| Component: | Embedded Media Thumbnail |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Description
After upgrading to 6.x-1.11, the custom thumbnail files for emfield are getting deleted every few hours. I can go back through, attach new thumbnails, and everything looks fine for a few hours, but eventually the thumbnail files simply disappear from the site's files/ directory again.
I am using:
Drupal Core 6.14
cck-6.x-2.5
emfield-6.x-1.11
thickbox-6.x-1.5
I am also using a per-content-type "image path" so the thumbnails are kept in sub-directories:
files/contenttype1-thumbnails/
files/contenttype2-thumbnails/
etc.
It is these sub-directories that are getting cleared out every few hours.

#1
Ok, I have an update on this. Not surprisingly, when I look in the {files} table after uploading new thumbnail images, their status = 0. So when system.cron comes through to do garbage collection, the thumbnails have status FILE_STATUS_TEMPORARY, and get deleted.
After a quick grep for FILE_STATUS_, I can see that in emthumb_fetch_remote_thumbnail(), $file->status is explicitly set to FILE_STATUS_PERMANENT, but that is the only instance of the string "FILE_STATUS_" in the module, so my guess is that this is not getting done when updating a thumbnail (only when fetching a remote thumbnail set by the provider).
#2
I think I have figured this problem out. In the switch statement inside of emthumb_emfield_field_extra(), the 'update' and 'insert' cases appear twice. Upon testing, it looks like this led to _emthumb_file_update() never getting called (because it was inside the second 'update' case).
I'll post a patch here soon.
#3
The attached patch does two things:
1) It comments out the empty 'update' and 'insert' cases in emthumb_emfield_field_extra(). Prior to doing this, _emthumb_file_update() was never getting called - after the first 'update' case (and subsequent break), the second 'update' case would never match. This fixes my problem with thumbnails disappearing.
2) I updated the call to file_set_status() on line 458 to use the constant FILE_STATUS_PERMANENT instead of 1. Obviously this doesn't have any impact on the bug in question, but it is better form (and it makes it easier to search for "FILE_STATUS_" when debugging). ^_^
#4
Although I think this patch indeed works, I may have found a problem: after using Views Bulk Operations to promote content to the frontpage, the thumnails were lost again. Despite the patch from #3.
#5
I'm marking this as fixed because this is now officially a Drupal problem (see #302240: button broken due to fix various problems when using form storage ) and this is addressed by another patch (see #638758: Fixes and improvements to emthumb)
#6
Actually, marking as "Needs Review", since I'm not sure if Eric's patch is addressed in the previous issue and don't have time to check atm.
#7
#8
+1 I'm running into this one.