Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 357811 - sys-apps/file-5.05 breaks dev-php5/pecl-fileinfo
Summary: sys-apps/file-5.05 breaks dev-php5/pecl-fileinfo
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: Normal major (vote)
Assignee: PHP Bugs
URL: https://bugs.php.net/bug.php?id=54241
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-07 19:28 UTC by Jeroen Roos
Modified: 2013-01-02 18:01 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeroen Roos 2011-03-07 19:28:52 UTC
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
Comment 1 Samuli Suominen (RETIRED) gentoo-dev 2011-03-07 19:33:22 UTC
Duplicate of bug 288043 ?
Comment 2 Jeroen Roos 2011-03-07 20:31:07 UTC
(In reply to comment #1)
> Duplicate of bug 288043 ?

I found that one too, it looks similar, but it's for an older version.
Comment 3 Jeroen Roos 2011-03-08 07:56:44 UTC
@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.
Comment 4 Denny Reeh 2011-03-08 08:55:06 UTC
(In reply to comment #0)

Do you have a simple php test script?
Comment 5 Jeroen Roos 2011-03-08 09:01:34 UTC
(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.
Comment 6 Ole Markus With (RETIRED) gentoo-dev 2011-03-08 09:07:28 UTC
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
Comment 7 Jeroen Roos 2011-03-08 10:25:22 UTC
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.
Comment 8 Denny Reeh 2011-03-08 10:49:11 UTC
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.
Comment 9 Ole Markus With (RETIRED) gentoo-dev 2011-03-13 10:13:59 UTC
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.
Comment 10 Ole Markus With (RETIRED) gentoo-dev 2013-01-02 18:01:32 UTC
This was fixed upstream around 5.3.11