The first commit to DRUPAL-5 after the DRUPAL-5--1-5 tag has introduced some fairly serious bugs in imagecache_cache(). There's a $tmpdestination
variable being passed to getimagesize(), but that variable is never declared. Looking at the CVS archeology, it seems that this variable used to be heavily used in this function, but was mostly removed in the name of "cleaned up lock/tmp file handling". ;) The result is that the function tries to grab the filesize on a non-existent filename, which then results in a divide by zero:
warning: Division by zero in .../sites/all/modules/imagecache/imagecache.module on line 169.
warning: getimagesize(imagecache/thumbnail/files/images/foo.jpg) [function.getimagesize]: failed to open stream: No such file or directory in .../sites/all/modules/imagecache/imagecache.module on line 208.
warning: filesize() [function.filesize]: stat failed for imagecache/thumbnail/files/images/foo.jpg in .../sites/all/modules/imagecache/imagecache.module on line 209.
So, I fixed the code to use $tmp
instead of $tmpdestination
, but then I hit some other errors at the end of the function when you're trying to use $dst
. That's still just a relative path, yet you're using it for functions like filesize()
that need an absolute path. So, instead of wrapping all of those in file_create_path()
, I just called that once to initialize a $final_path
variable which we then use in all the right spots.
In my testing, the attached patch now makes DRUPAL-5 work without error when generating a new derivative.
Sorry for including it in the same patch, but this also fixes some tabs vs. spaces issues and using {} around if () for better code style, since it was right next to the lines I was fixing anyway. ;)
Comment | File | Size | Author |
---|---|---|---|
imagecache-1.19.2.36-bugs.patch | 2.05 KB | dww |
Comments
Comment #1
fighella CreditAttribution: fighella commentedAwesome fix so far! Worked a treat. The issue was driving me insane! Thanks alot for the help! ;)
JD
Comment #2
paulnem CreditAttribution: paulnem commentedThis issue seems to have made it into the 1.6 release without this patch, a number of users are now having the problem (further described at : http://drupal.org/node/277030 )
I've applied this patch to my 5.x-1.6 install, it appears to work well. Not sure if it needs to be updated at all for the newer version of imagecache.
Would be good to get some others testing this patch and get a new release done.
Just as an added note, I took this as an opportunity to try out thickbox 2.0 and imagecache 2.1. I've resolved the issues I had with upgrading to thickbox so I don't see a reason not to use imagecache 2.1 where THIS issue isn't present. I'll be upgrading my prod site in the next couple of weeks and suggest you do the same if possible.
Comment #3
dopry CreditAttribution: dopry commentedcommitted to DRUPAL-5
Comment #4
dwwYay, thanks. :)
Comment #5
yan CreditAttribution: yan commentedI'm getting the following errors with 5.x-1.6, shouldn't the problem be fixed as stated above? Or am I getting something wrong? What does "committed to DRUPAL-5" mean? Should I use the dev version?
Comment #6
paulnem CreditAttribution: paulnem commentedIndeed, either downgrade to 1.5, use the patch or get the dev version of the module.
Comment #7
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.