mime_magic errors with php4

I went to a customer for our three-weekly sprint review, I opened my mail there and it was full with hundreds of failed cronjobs. Ah, shit! Another night at the datacenter? But it wasn’t that bad :)

The server had ran an update of php that night and it broke. When I ran php4 from the commandline I got these errors:

PHP Warning: mime_magic: type search/400 \\input text/x-tex invalid in Unknown on line 0
PHP Warning: mime_magic: type search/400 \\section text/x-tex invalid in Unknown on line 0
PHP Warning: mime_magic: type search/400 \\setlength text/x-tex invalid in Unknown on line 0
PHP Warning: mime_magic: type search/400 \\documentstyle text/x-tex invalid in Unknown on line 0
PHP Warning: mime_magic: type search/400 \\chapter text/x-tex invalid in Unknown on line 0
PHP Warning: mime_magic: type search/400 \\documentclass text/x-tex invalid in Unknown on line 0
PHP Warning: mime_magic: type regex [Cc]onstant[[:space:]]+[Ss]tory text/x-inform invalid in Unknown on line 0

Wait a minute… I know these errors! But, of course, I hadn’t documented the solution when I first fixed them. So after much searching I found the workarround again:

In the /usr/share/misc/magic.mime file, find the section that begins "# TeX documents, from Daniel Quinlan" and comment out the lines in that section.

# TeX documents, from Daniel Quinlan (quinlan@yggdrasil.com)
#0 search/400 \\input text/x-tex
#0 search/400 \\section text/x-tex
#0 search/400 \\setlength text/x-tex
#0 search/400 \\documentstyle text/x-tex
#0 search/400 \\chapter text/x-tex
#0 search/400 \\documentclass text/x-tex

# Type: Inform interactive fiction language
# URL: http://www.inform-fiction.org/
# From: Reuben Thomas
#0 regex [Cc]onstant[[:space:]]+[Ss]tory text/x-inform

NOTE: For Debian, it appears that this file is located at /usr/share/file/magic.mime!

4 comments ↓

#1 Kisho on 07.16.08 at 10:54

It is a know problem. Debian had been sloppy in work. You will get this error on every mimeupdate. Simply give the file the chmod 555 also “chmod 555 /usr/share/file/magic.mime”. The next Update, will not change this File.
The problem is that Debian does not ask what shall happen with the file and it simply overwrites. DPKG looks not for differents between the file of the package and the local. This is a error in the postinstall script. The Maintainer is Brian White. I has an e-mail fairly often already sent it but not got any answer. So we have fix it every time or change the write permissions …

So far
Kisho Shin

#2 Zeratul on 04.12.09 at 17:34

Thanks for article and for comment guys ;)

#3 | 0×23 on 01.26.10 at 12:27

[...] diesen Blog Eintrag wusste ich wo zu suchen ist und hab kurzerhand das ganze mit in die Aktualisierung [...]

#4 Alex Owen on 06.18.10 at 15:21

chmod is not the solution
dpkg-divert is your friend…. read the man page.

The problem is that php does not recognise the new syntax of /usr/share/file/magic.mime . Really we should reconfigure PHP to look at its own private copy of mime.magic and fix that private copy.

Leave a Comment