After updating to file-5.05, fileinfo in PHP no longer works: PHP Warning: finfo::finfo(): Failed to load magic database at '/usr/share/misc/magic.mgc'. in /var/www/photo/htdocs/file.inc.php on line 271 Warning: finfo::finfo(): Failed to load magic database at '/usr/share/misc/magic.mgc'. in /var/www/photo/htdocs/file.inc.php on line 271 PHP Warning: finfo::file(): The invalid fileinfo object. in /var/www/photo/htdocs/file.inc.php on line 272 Warning: finfo::file(): The invalid fileinfo object. in /var/www/photo/htdocs/file.inc.php on line 272 This is PHP 5.3.5-pl0-gentoo with built-in fileinfo (no PECL-fileinfo). Rolling back to 5.04 resolves the issue. Reproducible: Always
Duplicate of bug 288043 ?
(In reply to comment #1) > Duplicate of bug 288043 ? I found that one too, it looks similar, but it's for an older version.
@Jeroen Roovers, Re: Summary change: It's not pecl-fileinfo that breaks, since PHP5.3 has fileinfo built-in. I do not have pecl-fileinfo installed.
(In reply to comment #0) Do you have a simple php test script?
(In reply to comment #4) > (In reply to comment #0) > > Do you have a simple php test script? No I don't, but I can write one. Will try to have that up here tonight.
I could not reproduce this using the example at http://no2.php.net/manual/en/function.finfo-file.php using file-5.05 and php-5.3.5
OK, I created a very simple test script: <?php $fileinfo=new finfo(FILEINFO_MIME, "/usr/share/misc/magic.mgc"); var_dump($fileinfo->file("/tmp/test.jpg")); ?> With 5.04: string(26) "image/jpeg; charset=binary" With 5.05: Warning: finfo::finfo(): Failed to load magic database at '/usr/share/misc/magic.mgc'. in /var/www/localhost/htdocs/fileinfo.php on line 2 Warning: finfo::file(): The invalid fileinfo object. in /var/www/localhost/htdocs/fileinfo.php on line 3 bool(false) However, if I change the script into: <?php $fileinfo=new finfo(FILEINFO_MIME); var_dump($fileinfo->file("/tmp/test.jpg")); ?> It DOES work with both 5.04 and 5.05. I just can't figure out which Magic file it is using then. http://nl.php.net/manual/en/function.finfo-open.php seems to suggest it would use /usr/share/misc/magic.mgc. Anyway, I have kept a copy of the magic before downgrade and found this: $ file magic.* magic.backup: magic binary file for file(1) cmd (version 8) (little endian) magic.mgc: magic binary file for file(1) cmd (version 7) (little endian) Apparently my PHP version cannot handle version 8 magic files.
i can reproduce the finfo issue with your test script. thank you for this. i do not think, this is a php problem, because the actual php fileinfo extension do not support libmagic version greater than 5.03. sys-apps/file is the package for the libmagic. here is the documentation of bundled libmagic in php: http://nl.php.net/manual/en/fileinfo.installation.php so you have to use bundled libmagic or feel free to use sys-apps/file-5.04 maybe in next php releases, the libmagic is updated. you can write a bug in bugs.php.net for version bump. i've not found anyone.
Regarding file, we always use the PHP bundled version because of its patching. The only problem is the unsupported magic file. I doubt that they will upgrade the magic library for the next release since it is already more or less out the door. So for now we can bug upstream about upgrading its bundled file and until they do, either do not specify a magic file (which for some reason works) or keep a copy of an older version.
This was fixed upstream around 5.3.11