8 use MediaWikiCoversValidator;
16 $this->mimeAnalyzer =
new MimeAnalyzer( [
17 'infoFile' =>
$IP .
"/includes/libs/mime/mime.info",
18 'typeFile' =>
$IP .
"/includes/libs/mime/mime.types",
20 'http://www.w3.org/2000/svg:svg' =>
'image/svg+xml',
21 'svg' =>
'image/svg+xml',
22 'http://www.lysator.liu.se/~alla/dia/:diagram' =>
'application/x-dia-diagram',
23 'http://www.w3.org/1999/xhtml:html' =>
'text/html',
24 'html' =>
'text/html',
32 $method = $class->getMethod(
'doGuessMimeType' );
33 $method->setAccessible(
true );
34 return $method->invokeArgs( $this->mimeAnalyzer, $parameters );
44 $actualMime = $this->mimeAnalyzer->improveTypeFromExtension( $oldMime,
$ext );
50 [
'gif',
'image/gif',
'image/gif' ],
51 [
'gif',
'unknown/unknown',
'unknown/unknown' ],
52 [
'wrl',
'unknown/unknown',
'model/vrml' ],
53 [
'txt',
'text/plain',
'text/plain' ],
54 [
'csv',
'text/plain',
'text/csv' ],
55 [
'tsv',
'text/plain',
'text/tab-separated-values' ],
56 [
'js',
'text/javascript',
'application/javascript' ],
57 [
'js',
'application/x-javascript',
'application/javascript' ],
58 [
'json',
'text/plain',
'application/json' ],
59 [
'foo',
'application/x-opc+zip',
'application/zip' ],
60 [
'docx',
'application/x-opc+zip',
61 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ],
62 [
'djvu',
'image/x-djvu',
'image/vnd.djvu' ],
63 [
'wav',
'audio/wav',
'audio/wav' ],
72 $oggFile = __DIR__ .
'/../../../data/media/say-test.ogg';
73 $actualType = $this->mimeAnalyzer->getMediaType( $oggFile,
'application/ogg' );
82 $oggFile = __DIR__ .
'/../../../data/media/say-test.opus';
83 $actualType = $this->mimeAnalyzer->getMediaType( $oggFile,
'application/ogg' );
91 $file = __DIR__ .
'/../../../data/media/say-test-with-id3.mp3';
92 $actualType = $this->mimeAnalyzer->getMediaType( $file );
100 $file = __DIR__ .
'/../../../data/media/say-test-with-id3.mp3';
109 $file = __DIR__ .
'/../../../data/media/say-test-mpeg1.mp3';
118 $file = __DIR__ .
'/../../../data/media/say-test-mpeg2.mp3';
127 $file = __DIR__ .
'/../../../data/media/say-test-mpeg2.5.mp3';
136 $file = __DIR__ .
'/../../../data/media/zip-in-doc.doc';
138 $this->
assertEquals(
'application/msword', $actualType );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
doGuessMimeType(array $parameters=[])
testZipInDoc()
A ZIP file embedded in the middle of a .doc file is still a Word Document.
testMP3WithID3Recognize()
Test to make sure that MP3 with id3 tag is recognized.
testImproveTypeFromExtension( $ext, $oldMime, $expectedMime)
providerImproveTypeFromExtension
testMP3NoID3RecognizeMPEG2()
Test to make sure that MP3 without id3 tag is recognized (MPEG-2 sample rates)
testOggRecognize()
Test to make sure that encoder=ffmpeg2theora doesn't trigger MEDIATYPE_VIDEO (T65584)
testMP3NoID3RecognizeMPEG1()
Test to make sure that MP3 without id3 tag is recognized (MPEG-1 sample rates)
providerImproveTypeFromExtension()
testMP3NoID3RecognizeMPEG2_5()
Test to make sure that MP3 without id3 tag is recognized (MPEG-2.5 sample rates)
MimeAnalyzer $mimeAnalyzer
testOpusRecognize()
Test to make sure that Opus audio files don't trigger MEDIATYPE_MULTIMEDIA (bug T151352)
testMP3AsAudio()
Test to make sure that mp3 files are detected as audio type.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
if(!is_readable( $file)) $ext