Bug->Doc #64793 [Nab->Asn]: finfo_open raises warning with env magic file

From: Date: Thu, 16 May 2013 19:10:43 +0000
Subject: Bug->Doc #64793 [Nab->Asn]: finfo_open raises warning with env magic file
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-9831@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64793&edit=1 ID: 64793 Updated by: aharvey@php.net Reported by: weierophinney@php.net Summary: finfo_open raises warning with env magic file -Status: Not a bug +Status: Assigned -Type: Bug +Type: Documentation Problem -Package: Filesystem function related +Package: Documentation problem Operating System: Ubuntu 13.04 PHP Version: 5.4.14 -Assigned To: +Assigned To: aharvey Block user comment: N Private report: N New Comment: Morphing into a doc bug. I think this one changed when we started bundling libmagic, as the relevant code appears to be commented out, but I'll check before fixing the manual. Previous Comments: ------------------------------------------------------------------------ [2013-05-09 13:09:20] weierophinney@php.net 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. ------------------------------------------------------------------------ [2013-05-09 07:50:37] ab@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] weierophinney@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

« previous php.doc.bugs (#9831) next »