php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #22275 CLI and --enable-mime-magic Spews Warnings
Submitted: 2003-02-18 09:46 UTC Modified: 2003-03-31 13:38 UTC
From: hans at nyu dot edu Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.3.1 OS: RedHat 6.2 (2.2.14)
Private report: No CVE-ID: None
 [2003-02-18 09:46 UTC] hans at nyu dot edu
Hopefully I'm not missing something obvious.  After downloading PHP 4.3.1 to a RedHat 6.2 box, I configured and compiled like so for use as a CLI bin:

./configure
--prefix=/usr/local/psh --disable-cgi
--disable-ipv6 --with-openssl=/usr/local/ssl
--with-zlib --enable-bcmath
--with-bz2 --enable-dio
--enable-ftp --enable-mime-magic
--with-mysql=/usr/local/mysql --with-ncurses
--enable-pcntl --with-readline
--enable-shmop --enable-sockets
--enable-sysvmsg --enable-sysvsem
--enable-sysvshm

Everything happily compiles and installs, but when finally running the binary as /usr/local/psh/bin/php -v the following is spewed out:

HTTP/1.0 0 X
Content-type: text/html

PHP Warning:  mime_magic: (line 3859) offset `&0	string		>\0			%s			' invalid in Unknown on line 0
PHP Warning:  mime_magic: type &0	string		>\0			%s			 invalid in Unknown on line 0
PHP Warning:  mime_magic: (line 3860) offset `&0	string		>\0			%s			' invalid in Unknown on line 0
PHP Warning:  mime_magic: type &0	string		>\0			%s			 invalid in Unknown on line 0
PHP Warning:  mime_magic: (line 3861) offset `&0	string		>\0			%s		' invalid in Unknown on line 0
PHP Warning:  mime_magic: type &0	string		>\0			%s		 invalid in Unknown on line 0
PHP Warning:  mime_magic: (line 3862) offset `&0	string		>\0			%s		' invalid in Unknown on line 0
PHP Warning:  mime_magic: type &0	string		>\0			%s		 invalid in Unknown on line 0
PHP 4.3.1 (cli) (built: Feb 17 2003 22:13:02)
Copyright (c) 1997-2002 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2002 Zend Technologies

The same type of output occurs whether I use php -h or just plain php with no arguments.  Looking at /usr/share/magic I've excerpted the lines as noted:

3848	# HP Printer Job Language
3849	0	string		\033%-12345X@PJL	HP Printer Job Language data
3850	# HP Printer Job Language
3851	# The header found on Win95 HP plot files is the "Silliest Thing possible" 
3852	# (TM)
3853	# Every driver puts the language at some random position, with random case
3854	# (LANGUAGE and Language)
3855	# For example the LaserJet 5L driver puts the "PJL ENTER LANGUAGE" in line 10
3856	# From: Uwe Bonnes <bon@elektron.ikp.physik.th-darmstadt.de>
3857	# 
3858	0	string		\033%-12345X@PJL	HP Printer Job Language data
3859	>&0	string		>\0			%s
3860	>>&0	string		>\0			%s
3861	>>>&0	string		>\0			%s  3862	>>>>&0	string		>\0			%s  3863	#>15	string		\ ENTER\ LANGUAGE\ =
3864	#>31	string		PostScript		PostScript

If I then make distclean and ./configure just as above, but without --enable-mime-magic everything looks as it should.  Should CLI and --enable-mime-magic not be used together?  Hopefully this all makes sense to someone and this message comes out readable.

Thanks,

Hans

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-18 11:57 UTC] moriyoshi@php.net
mime magic extension only supports simplified magic files that come with Apache distribution for now, as most part of its code is taken from mod_mime_magic.

 [2003-02-18 12:58 UTC] hans at nyu dot edu
OK, this makes sense then.  If I set the following in php.ini:

mime_magic.magicfile = "/usr/local/apache/conf/magic"

everything appears fine.  If I also set that directive to a non-existent file, I don't get the Warning either.  However, if I set it to my system's magicfile, /usr/share/magic, I get the warnings.

With your clarification this makes sense, however maybe this is a documentation issue.  While http://www.php.net/manual/en/ref.mime-magic.php says this extension is derived from Apache mod_mime_magic, the Installation and Runtime Configuration sections are misleading, in my opinion.

In Installation:

"The extension needs a copy of the magic.mime as distributed with the file command. This file also part of most recent Linux distributions and usually stored in the /usr/share/misc directory."

And in Runtime Configuration the default value "/usr/share/misc/magic.mime" seems that it would never be a correct value.

Oddly enough, the default /usr/share/misc/magic.mime file doesn't exist on my system, and without the mime_magic.magicfile directive set, I still receive the Warnings.  I mention this as odd because when setting the directive explicitly to a non-existent file I don't get any warnings.

Anyway, thanks for the clarification,

Hans
 [2003-02-18 13:01 UTC] moriyoshi@php.net
Now marking this as Documentation Problem.

 [2003-03-31 13:38 UTC] moriyoshi@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 [2020-02-07 06:12 UTC] phpdocbot@php.net
Automatic comment on behalf of moriyoshi
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=b0f6477bc408b7e2840566c64604c5bcfefb018d
Log: Fixed bug #22912 and #22275
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 29 12:00:02 2025 UTC