Index: MimeMagic.php =================================================================== --- MimeMagic.php (revision 55559) +++ MimeMagic.php (working copy) @@ -474,6 +474,7 @@ * Warning: this is a heuristic, and won't match a file with a lot of non-PHP before. * It will also match text files which could be PHP. :) */ + $phpmatch = false; if( ( strpos( $head, 'wellFormed ) { global $wgXMLMimeTypes; - if( isset( $wgXMLMimeTypes[$xml->getRootElement()] ) ) { + if ( $phpmatch ) { + return $phpmatch; + } elseif ( isset( $wgXMLMimeTypes[$xml->getRootElement()] ) ) { return $wgXMLMimeTypes[$xml->getRootElement()]; } else { return 'application/xml'; @@ -537,7 +551,12 @@ $match = array(); if ( preg_match( '%/?([^\s]+/)(\w+)%', $head, $match ) ) { - $mime = "application/x-{$match[2]}"; + if ( $phpmatch ) { + $mime = $phpmatch; + } + else { + $mime = "application/x-{$match[2]}"; + } wfDebug( __METHOD__.": shell script recognized as $mime\n" ); return $mime; } @@ -566,6 +585,10 @@ return 'image/vnd.djvu'; } + if ( $phpmatch ) { + wfDebug( __METHOD__.": failed to detect other type for file $file, default to $phpmatch\n" ); + return $phpmatch; + } return false; }