Jump to content

Manual talk:MimeMagic.php

Add topic
From mediawiki.org
Latest comment: 4 years ago by Wladek92 in topic MimeMagic replaced by MimeAnalyzer

Hack for function doGuessMimeType()[edit]

I had the problem that doGuessMimeType found an MS Word 2007 file was a zip (mentioned multiple times in other discussions - i know) and because of that $wgMimeDetectorCommand never came into account i felt to manipulate this function. May someone please tell me if this is usefull?

        function guessMimeType( $file, $ext = true ) {
                $mime = $this->doGuessMimeType( $file, $ext );
                if( !$mime ) {
                        wfDebug( __METHOD__.": internal type detection failed for $file (.$ext)...\n" );
# RDO 20100504 manipulation: take detectMimeType in consieration
                $mime2 = $this->detectMimeType( $file, $ext );
                if($mime2 !== false && $mime !== $mime2){
                        wfDebug( __METHOD__.": doGuessMimeType guessed $mime while detectMimeType detected $mime2... will take $mime2 and go on...\n" );
                        $mime = $mime2;
# RDO 20100504 end of manipulation

                if ( isset( $this->mMimeTypeAliases[$mime] ) ) {
                        $mime = $this->mMimeTypeAliases[$mime];

                wfDebug(__METHOD__.": final mime type of $file: $mime\n");
                return $mime;

I would be pleased for any response! --RaZe 16:59, 4 May 2010 (UTC)Reply

MimeMagic replaced by MimeAnalyzer[edit]

The MimeMagic class, deprecated since 1.28 has been removed. Get a MimeAnalyzer instance from MediaWikiServices instead.
See Topic:Vho2o28hvu52yik1

Christian FR (talk) 16:13, 29 February 2020 (UTC)Reply