when getting file (img) properties, suppress whines that it's not xml
[lhc/web/wiklou.git] / includes / libs / mime / MimeAnalyzer.php
index 631bb17..d6c87b6 100644 (file)
@@ -643,9 +643,9 @@ EOT;
         */
        private function doGuessMimeType( $file, $ext ) {
                // Read a chunk of the file
-               MediaWiki\suppressWarnings();
+               Wikimedia\suppressWarnings();
                $f = fopen( $file, 'rb' );
-               MediaWiki\restoreWarnings();
+               Wikimedia\restoreWarnings();
 
                if ( !$f ) {
                        return 'unknown/unknown';
@@ -760,7 +760,9 @@ EOT;
                /**
                 * look for XML formats (XHTML and SVG)
                 */
+               Wikimedia\suppressWarnings();
                $xml = new XmlTypeCheck( $file );
+               Wikimedia\restoreWarnings();
                if ( $xml->wellFormed ) {
                        $xmlTypes = $this->xmlTypes;
                        if ( isset( $xmlTypes[$xml->getRootElement()] ) ) {
@@ -833,9 +835,9 @@ EOT;
                        }
                }
 
-               MediaWiki\suppressWarnings();
+               Wikimedia\suppressWarnings();
                $gis = getimagesize( $file );
-               MediaWiki\restoreWarnings();
+               Wikimedia\restoreWarnings();
 
                if ( $gis && isset( $gis['mime'] ) ) {
                        $mime = $gis['mime'];
@@ -988,18 +990,8 @@ EOT;
                $m = null;
                if ( $callback ) {
                        $m = $callback( $file );
-               } elseif ( function_exists( "finfo_open" ) && function_exists( "finfo_file" ) ) {
-                       $mime_magic_resource = finfo_open( FILEINFO_MIME );
-
-                       if ( $mime_magic_resource ) {
-                               $m = finfo_file( $mime_magic_resource, $file );
-                               finfo_close( $mime_magic_resource );
-                       } else {
-                               $this->logger->info( __METHOD__ .
-                                       ": finfo_open failed on " . FILEINFO_MIME . "!\n" );
-                       }
                } else {
-                       $this->logger->info( __METHOD__ . ": no magic mime detector found!\n" );
+                       $m = mime_content_type( $file );
                }
 
                if ( $m ) {