ZF-11784: Zend_Validate_File_MimeType does not permit user to disable the auto discovery of magic files
Since version 5.3.x (poorly documented) PHP has included its own libmagic library, including custom patches. It presumably also includes a built-in mime file definition (not documented anywhere, but observed anecdotally by myself and another: http://php.net/manual/en/…).
A problem occurs when PHP is in use on systems that use a version of libmagic and the associated mime magic files that conflicts with what PHP is using internally. When using finfo_open() and explicitly specifying the system magic file to use then most (all?) files will be identified as "application/octet-stream" instead of the proper type. However, when using finfo_open() and omitting the second parameter PHP is able to successfully identify file mime types as expected.
Note that despite the finfo_open() documentation regarding the second parameter: "If this variable is not set either, /usr/share/misc/magic is used by default", is incorrect. That, or PHP is behaving differently when implicitly using the default magic file than when that same file is explicitly specified. This can be demonstrated and tested using the simple script located here: https://gist.github.com/1252125
This occurs in CentOS 5.6 and 5.7 with IUS PHP packages, and potentially other environments.
Sorry for the amount of background info. The problem that Zend_Validate_File_MimeType has is that it does not permit the developer to specify that we don't want it to attempt to use the list of "common" locations for mime magic files. Nor does it permit us to modify or override them in any fashion.
Zend_Validate_File_MimeType::getMagicFile() currently will always attempt to utilize the $_magicFiles list if the magic file has not been explicitly set. ZVFMT::setMagicFile() does not permit passing "false" or "null" to indicate that we do not desire those files be used.
I'm thinking a ZVFMT::disableAutoMagicFileUsage() method that simply sets a boolean property (default true) is the simplest and best solution.