php.net |  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
Votes:2
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gregor at gregor dot ru
New email:
PHP Version: OS:

 

 [2008-09-05 07:33 UTC] gregor at gregor dot ru
Description:
------------
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:
---------------
$filename='/webserver/sites/test/uploads/test.jpg';
$finfo = new finfo(FILEINFO_MIME, '/webserver/php/magic');
if (!$finfo) die("Can't open mime database");
$res = $finfo->file($filename);
print($res);

Expected result:
----------------
image/jpeg

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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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):
putenv('MAGIC=/usr/share/file/magic');
=> 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: 
/usr/share/misc/magic.mime


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] yohgaki@php.net
-Status: Open +Status: Closed -Package: Fileinfo +Package: PECL -Assigned To: +Assigned To: yohgaki
 [2014-07-15 10:46 UTC] yohgaki@php.net
I suppose this could be closed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 10:01:29 2024 UTC