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.

CommentFileSizeAuthor
#3 emthumb_2161012-2.patch999 byteseric at nrd

Comments

eric at nrd’s picture

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).

eric at nrd’s picture

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.

eric at nrd’s picture

StatusFileSize
new999 bytes

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). ^_^

Anonymous’s picture

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.

alex ua’s picture

Status: Active » Fixed

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)

alex ua’s picture

Status: Fixed » Active

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.

alex ua’s picture

Status: Active » Needs review
jjesus’s picture

+1 I'm running into this one.

aaron’s picture

aaron’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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