I have a site which uses imagefields and imagecache modules, in addition to the the imce module. The file system is a private file system, so hook_file_download() gets invoked each time an image is viewed/downloaded. However, as imagecache generates images as needed, the images don't always exist when imce_file_download() is called. This means that the function filesize() on line 104 of imce.module is being called on a non-existent file, giving a php error like:

filesize() [<a href='function.filesize'>function.filesize</a>]: stat failed for 1 in sites/all/modules/imce/imce.module on line 104.

I tried changing the weights of the modules in the system but the problem still occurred. Ideally the imce module should only return the appropriate headers (or -1) if that image is controlled by the module, and return NULL otherwise. As imagecache images are not imce images, shouldn't it return NULL for them? That's a bigger change though and is open to debate, so the quick solution is to ensure that the file exists before executing that code, which is what the attached patch does.

Cheers,
Stella

CommentFileSizeAuthor
#1 722176.patch1.67 KBstella
hook_file_download.patch694 bytesstella

Comments

stella’s picture

StatusFileSize
new1.67 KB

Patch re-roll.

ufku’s picture

Version: 6.x-1.x-dev » master
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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