Why do I get "Failed to load magic database at '/usr/share/file/magic'" error in my error_log on CentOS running Omeka?
I've installed Omeka on CentOS 5.5 with PHP 5.3 from IUS and I get " Failed to load magic database at '/usr/share/file/magic' " when I try to upload a .png. What's going on?
I don't know. Maybe the magic files distributed with something CentOS-y are not valid -- I've been too lazy to look. However, if you just let finfo() do its work without trying to outsmart it by specifying the path to the magic database file, then it might just work for you.
I don't normally advocate editing distribution source, but so many people have this problem out there it seems and there is a different solution for every LAMP distribution/version permutations, that, hey, what the heck.
One way to do it, down under your Omeka install direcotry find:
Edit it and comment out all the lines populating the $_magicFiles array. This is around lines 87-95. This'll make the array empty. If the MAGIC env var is set in the httpd process however (look at the environment section of a phpinfo() output) then MimeType.php will use that. If that's the case, you have to be more drastic, I guess, for this kluge of a solution and mess with the isValid() function in MimeType.php and do something about:
$mime=new finfo($const, $mimefile);
around line 298. You could just delete the ", $mimefile" argument, for example.
I'm sorry you ran into this problem, too. I really am. I spent a lot of wasted time looking for ways to solve it the right way without getting to much into the magic files because I don't feel like learning about them right now. Let me know if you find the right solution.
By the way, if you comment out all but /usr/share/mime/magic in that array in MimeType.php, it'll still fail, but this time detect the file as an application/octet-stream, which by default Omeka rejects. So, my gut says the problem is really invalid magic files.
Add a Comment
NOTE: Comments are moderated and will not show until approved.