ID:               48885
 Updated by:       phi...@php.net
 Reported By:      majkl578 at gmail dot com
-Status:           Closed
+Status:           Feedback
 Bug Type:         Filesystem function related
 Operating System: Linux Debian
 PHP Version:      5.3.0
 New Comment:


Which version of libmagic changed this? It should be added to the docs.


Also, the docs don't mention how to link to libmagic nor mention that a

bundled version is used [by default]. What's the situation? The only 
option I see with './configure --help' is --disable-fileinfo ...


Previous Comments:
------------------------------------------------------------------------

[2009-07-27 03:16:33] s...@php.net

Automatic comment from SVN on behalf of scottmac
Revision: http://svn.php.net/viewvc/?view=revision&revision=286383
Log: Update documentation to reflect change with the internal libmagic
updates. See bug #48885

------------------------------------------------------------------------

[2009-07-27 02:55:44] scott...@php.net

Looked into this tonight again and from 5.3+ there are two new
constants available, FILEINFO_MIME_TYPE provides the old behavior.

I'll add them both to the documentation tonight.

------------------------------------------------------------------------

[2009-07-26 22:31:17] scott...@php.net

Matthew, you can get the behavior with PHP 5.2 if you link against a
newer version of libmagic. This wasn't a change to any of the PHP
wrapper code in this case.

So yes it might be a BC break for you, but in reality its a bug fix.

------------------------------------------------------------------------

[2009-07-26 21:48:21] paj...@php.net

Matthew,

That's exactly why the status of this report is set to "to be
documented".

------------------------------------------------------------------------

[2009-07-26 21:43:19] matthew at zend dot com

I beg to differ a bit here with the assertion that the change is not a
BC break.

Consider this: in versions prior to 5.3.0, one could do a match like
this:

$finfo = new finfo(FILEINFO_MIME);
$type = $finfo->file($filename);
if (!in_array($type, array('image/jpeg', 'image/jpg'))) {
    echo "Invalid image type.";
} else {
    echo "JPEG found."
}

Now, with 5.3.0, this changes; the same assertion no longer works. This
is in fact exactly an issue we had with Zend_Validate_File_MimeType when
testing against PHP 5.3.0 -- matching that worked in 5.2.x now no longer
works in 5.3.0. We have altered our library to handle the strings
returned by both versions, but that exactly disproves your point: if the
new behavior were BC, we wouldn't *need* to update our code.

I feel at the very least, the fact that the MIME type returned also
includes encoding information, and the format of this encoding
information, needs to be documented in the manual, and likely the
UPGRADING guide.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/48885

-- 
Edit this bug report at http://bugs.php.net/?id=48885&edit=1

Reply via email to