Same issue... Fileinfo could not load the magic file....
havran - April 3, 2008 - 19:48
| Project: | MimeDetect |
| Version: | 6.x-1.2 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | duplicate |
Description
Hi. I use FileField 5.x-2.3-rc3 with MimeDetect 5.x-1.0-beta on my web hosting:
- PHP Version 5.2.4
- System FreeBSD 6.2-STABLE
I have this error on Status Report page
finfo_open() [<a href='function.finfo-open'>function.finfo-open</a>]: Failed to load magic database at '/home/html/enigmaczech.cz/public_html/sites/all/modules/content/mimedetect/magic'.with red message
Mime Detection PHP FileInfo Extension
FileInfo could not load the magic file. It could be corrupted. Try reinstalling the magic file distributed with the MimeDetect module.I test finfo_open() function in misc path but for me work only this variant finfo_open(FILEINFO_MIME) (without second parameter). Maybe we need test this and on this case use finfo_open() without second parameter.

#1
No, I specifically want to use the magic distributed with mime detect. I'll try to gain access to a freebsd machine to test out the magic installation on it. Can you try rebuilding the magic database to see if a local rebuild based on the distributed magic will work? I may need to have mime detect build the magic database from source if this proves to be a common portability problem.
#2
I try compile magic.mgc from magic file provide in MimeDetect 5.x-1.0-beta and i give many errors. I use command
file -C -m magicand i give:fem7# file -C -m magicmagic, 3003: Warning type `search/1 \0\0\0\0pwV1 Cracklib password index, big endian ("64-bit")' invalid
magic, 4002: Warning type `medate x Previous dump %s,' invalid
magic, 4003: Warning type `medate x This dump %s,' invalid
magic, 5262: Warning type `leqldate x last written at %s,' invalid
magic, 5265: Warning type `lequad x number of blocks %lld,' invalid
magic, 5266: Warning type `lequad x number of data blocks %lld,' invalid
magic, 5272: Warning type `lequad x pending blocks to free %lld,' invalid
magic, 5274: Warning type `lequad x system-wide uuid %0llx,' invalid
...
And finally:
fem7# file -vfile-4.12
magic file from /usr/share/misc/magic
I think on FreeBSD 6.2 is older version file library which not support some new magic file syntax. I have installed FreeBSD 7 on another machine and on this machine i compile provided magic file without problems.
#3
I have exactly the same problem. My server is FreeBSD also. I dont have the option for installing another version. Do I have a choice of using FileField with mimedetect or not?
thanks
#4
On my site i replace line 36 in mimedetect.module:
<?phpif (!$finfo = @finfo_open(FILEINFO_MIME, drupal_get_path('module', 'mimedetect') . '/magic')) {
?>
into
<?phpif (!$finfo = @finfo_open(FILEINFO_MIME)) {
?>
but this only remove error report in site status page...
#5
I've just encountered this problem on a FreeBSD 6.3 box. All of the proposed patches and fixes don't seem to work. The one patch I found seemed to apply to the installation script, not the module code. It's all rather confusing.
Can you briefly explain how the MimeDetect module installs its own magic files?
My system has them at /usr/share/misc/magic ... magic.mgc ... magic.mime ... magic.mime.mgc
The files in this directory are smaller than those in the mimedetect directory.
Should I be pointing fileinfo to the mimedetect directory or is the mimedetect module supposed to install them in the system directory? If the latter, is it ok to overwrite what's there?
There was mention of recompiling or reinstalling the magic file; how do I do this?
I am using KDE3.5.8 via PCBSD, so apparently other programs in KDE use the magic files that were already there. I obviously don't want to muck that up in the process.
Where do the magic files come from? If they need to be updated periodically, it would be nice to know how.
Thanks in advance, Jeff
#6
I have the same status page red box error: "Fileinfo could not load the magic file. It could be corrupted. Try reinstalling the magic file distributed with the MimeDetect module."
I replaced the magic.* files in /usr/share/file with those provided in the module and now sitting in /public_html/sites/all/modules/mimedetect, simply renaming the original files to magic_orig.*; however, there was not magic.mime.mgc so I left the orig one as it was.
I then rebooted the server. Is it necessary to recompile Magic?... How?
The server is running:
* Ubuntu 8.04.2
* Apache 2.2.11 Running
* PHP Version 5.2.9
* MySQL 5.0.67 Running
* Java: j2re1.4
#7
I managed to solve this on my windows box running wampserver2 by replacing the magic files provided with mimedetect with the attached files (per some thread I found on a php forum). I spent quite a bit of time trying to fix this and this was the only way I could find. Everything seems to be functioning ok.
#8
Bonjour.
is there another solution? I am hosted on Hostingrails.com (beginner plan, a shared server, Apache/2.2.4 (Unix) mod_ssl/2.2.4 OpenSSL/0.9.7a DAV/2 mod_auth_passthrough/1.8 mod_bwlimited/1.4 PHP/5.2.3 SVN/1.5.0 Phusion_Passenger/2.1.3).
I have installed the mimedetect 6.x-1.2. I have seen there is another dev version. What about it ?
#9
#306217: Fileinfo could not load the magic file will allow people to configure their own path.
#10
I’ve just had the same problem.
Here’s how I corrected it in my case :
I edited the magic file that comes with mimedetect because, under Ubuntu, the file -C -m magic command gave me these lines :
magic, 2170: Warning: <= not supported
magic, 2910: Warning: description `Clarion Personal/Professional Developer (v2 and above) data fil' truncated
magic, 2921: Warning: description `Clarion Personal/Professional Developer (v2 and above) memo dat' truncated
magic, 2927: Warning: description `Clarion Personal/Professional Developer (v2 and above) help dat' truncated
magic, 5854: Warning: <= not supported
magic, 5857: Warning: <= not supported
magic, 7791: Warning: >= not supported
magic, 8599: Warning: escaped tab found, use \t instead
Here’s how I edited the above lines :
2170 → replace <= by < and add 1 to the following number (less than or equal to is not understood but less than is understood)
2910 → replace "v2 and above" by "v2+" (line is apparently too long)
2921 → replace "v2 and above" by "v2+" (line is apparently too long)
2927 → replace "v2 and above" by "v2+" (line is apparently too long)
5854 → replace <= by < and add 1 to the following number (less than or equal to is not understood but less than is understood)
5857 → replace <= by < and add 1 to the following number
7791 → replace >= by > and subtract 1 to the following number (0x200 → 0x1FF)
8599 → replace tabulation character right after \ by a the t letter (tabulation character is forbidden)
After these modifications, file -C -m magic works without any error message and generates the magic.mgc file.
Copying magic and magic.mgc back to the server (Debian with PHP 5.2.6-1+lenny3) does wonder as it is automatically recognized when you go under admin/report/status.
The only trouble that may happen from now on : an update of mimedetect and the old file coming back.
I’ve attached my modified magic if it can helps someone.