|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58333 finfo::file() only generates error
Submitted: 2008-09-05 07:33 UTC Modified: 2014-07-15 10:46 UTC
Avg. Score:3.5 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: gregor at gregor dot ru Assigned: yohgaki (profile)
Status: Closed Package: PECL (PECL)
PHP Version: 5.2.5 OS: Windows XP SP3
Private report: No CVE-ID: None
 [2008-09-05 07:33 UTC] gregor at gregor dot ru
Fileinfo module isn't works. It generates exception.

I've checked $finfo object exactly before $finfo->file() call and get_classname() correctly returns "finfo" and 0 get_class_methods() returns "[0] => finfo [1] => set_flags [2] => file [3] => buffer".

BTW: There is not method "close"!

I'm using php 5.2.6 (!) and pecl package which comes with it.

Reproduce code:
$finfo = new finfo(FILEINFO_MIME, '/webserver/php/magic');
if (!$finfo) die("Can't open mime database");
$res = $finfo->file($filename);

Expected result:

Actual result:
Warning: finfo::file() [finfo.file]: The invalid fileinfo object.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-07 04:24 UTC] dragos dot rusu at ymail dot com
I can reproduce this also on Centos 5.2 with PHP 5.2.11 and Apache/2.2.3 (fileinfo installed within PECL).

If I set the environment (like manual says):
=> it's not taken into consideration

If I set as 2nd parameter the mime file like:
// file on disk: /etc/httpd/magic.mime
$finfo = new finfo(FILEINFO_MIME, '/etc/httpd/magic');
=> it validates the creation of the object but than I get a lot of errors like:
"Warning: finfo::file() [finfo.file]: The invalid fileinfo object. in /www/projects/andrei/fileinfo/fileinfo.php on line 38 1.xlsx"

So my only solution was to leave default PHP configuration and copy my magic file into: 

P.S. We cannot move to PHP 5.3 since we have an old(<2002) and large application and code was not refactored (yet! - hopefully).
 [2014-07-15 10:46 UTC]
-Status: Open +Status: Closed -Package: Fileinfo +Package: PECL -Assigned To: +Assigned To: yohgaki
 [2014-07-15 10:46 UTC]
I suppose this could be closed.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Jul 08 01:01:25 2020 UTC