r1pexpb / timthumb

Automatically exported from code.google.com/p/timthumb
0 stars 0 forks source link

Problem where finfo php extension is misconfigured on the server #44

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I came across an unusual error condition where the following error message 
was output:

Warning: finfo_open() [function.finfo-open]: Failed to load magic database 
at '/etc/magic'. in /htdocs/public/www/wp-
content/themes/starmagazine/scripts/timthumb.php on line 373

And as a result the image resize operation failed (headers already output).  
I'm guessing this occurs where the finfo php extension is not configured or 
installed correctly on the server, I fixed the code by adding some simple 
error checking for finfo_open(), please see following diff code:

373,375c373,376
<           $finfo = finfo_open(FILEINFO_MIME);
<           $mime_type = finfo_file($finfo, $file);
<           finfo_close($finfo);

---
>           if ($finfo = @finfo_open(FILEINFO_MIME)) {
>               $mime_type = finfo_file($finfo, $file);
>               finfo_close($finfo);
>           }

Would appreciate if you could include this patch in your svn trunk code.

Thanks!

Original issue reported on code.google.com by pieter.b...@gmail.com on 11 Nov 2009 at 12:54

GoogleCodeExporter commented 9 years ago
Hi - this fix is in the latest version of the code

Original comment by BinaryMoon on 31 Dec 2009 at 7:28