Edit report at https://bugs.php.net/bug.php?id=64793&edit=1
ID: 64793 Comment by: weierophin...@php.net Reported by: weierophin...@php.net Summary: finfo_open raises warning with env magic file Status: Not a bug Type: Bug Package: Filesystem function related Operating System: Ubuntu 13.04 PHP Version: 5.4.14 Block user comment: N Private report: N New Comment: After receiving the "answer" to this issue, I decided to run "unset MAGIC" in my shell, as the implication is that if you do this, PHP will use its own internal magic.mime database. This indeed works. Unfortunately, the documentation is completely wrong, which is why I never determined the correct course of action. It states: "Name of a magic database file, usually something like /path/to/magic.mime. If not specified, the MAGIC environment variable is used. If this variable is not set either, /usr/share/misc/magic is used by default. A .mime and/or .mgc suffix is added if needed. Passing NULL or an empty string will be equivalent to the default value." Clearly this is incorrect, as the default is actually to use the magic database PHP bundles. Previous Comments: ------------------------------------------------------------------------ [2013-05-09 07:50:37] a...@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php It's expected that the magic file format change across the libmagic versions. This way you may experience some difference even within the same version, libmagic was upgraded for 5.4.1 and now again in 5.4.15. The recommended way is to use the compiled in magic, passing a magic file from outside you have to care about the version compatibility. The same were obviously the experience if you use the file commando with different magic file versions. ------------------------------------------------------------------------ [2013-05-08 18:25:28] weierophin...@php.net Description: ------------ Using either the system magic file (/usr/share/file/magic.mgc) or the one shipped with PHP (http://lxr.php.net/xref/PHP_5_5/ext/fileinfo/tests/magic? r=12cf930a403d0bbee0c40a5e93554cafd6b0895e), and ensuring that my MAGIC env points to the file, any call to finfo_open() that does not specify a MIME file raises a warning: "offset `' invalid". This occurs in 5.3.3 and 5.4.14; I cannot reproduce it in 5.3.21. I've tried a variety of magic files, and not yet found one that works reliably across versions. Test script: --------------- $finfo = finfo_open(FILEINFO_MIME_TYPE); Expected result: ---------------- (no error) Actual result: -------------- finfo_open(): Warning: offset `' invalid ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64793&edit=1