22use Psr\Log\LoggerAwareInterface;
23use Psr\Log\LoggerInterface;
30class MimeAnalyzer
implements LoggerAwareInterface {
38 protected $initCallback;
40 protected $detectCallback;
42 protected $guessCallback;
44 protected $extCallback;
46 protected $mediaTypes =
null;
48 protected $mimeTypeAliases =
null;
50 protected $mimetoExt =
null;
53 public $mExtToMime =
null;
56 protected $IEAnalyzer;
59 private $extraTypes =
'';
61 private $extraInfo =
'';
85 protected static $wellKnownTypes = <<<EOT
86application/ogg ogx ogg ogm ogv oga spx
88application/vnd.oasis.opendocument.chart odc
89application/vnd.oasis.opendocument.chart-
template otc
90application/vnd.oasis.opendocument.database odb
91application/vnd.oasis.opendocument.formula odf
92application/vnd.oasis.opendocument.formula-
template otf
93application/vnd.oasis.opendocument.graphics odg
94application/vnd.oasis.opendocument.graphics-
template otg
95application/vnd.oasis.opendocument.image odi
96application/vnd.oasis.opendocument.image-
template oti
97application/vnd.oasis.opendocument.presentation odp
98application/vnd.oasis.opendocument.presentation-
template otp
99application/vnd.oasis.opendocument.spreadsheet ods
100application/vnd.oasis.opendocument.spreadsheet-
template ots
101application/vnd.oasis.opendocument.text odt
102application/vnd.oasis.opendocument.text-master otm
103application/vnd.oasis.opendocument.text-
template ott
104application/vnd.oasis.opendocument.text-web oth
105application/javascript js
106application/x-shockwave-flash swf
107audio/midi mid midi kar
108audio/mpeg mpga mpa mp2 mp3
109audio/x-aiff aif aiff aifc
114image/jpeg jpeg jpg jpe
122image/x-portable-pixmap ppm
136 protected static $wellKnownInfo = <<<EOT
137application/pdf [OFFICE]
138application/vnd.oasis.opendocument.chart [OFFICE]
139application/vnd.oasis.opendocument.chart-
template [OFFICE]
140application/vnd.oasis.opendocument.database [OFFICE]
141application/vnd.oasis.opendocument.formula [OFFICE]
142application/vnd.oasis.opendocument.formula-
template [OFFICE]
143application/vnd.oasis.opendocument.graphics [OFFICE]
144application/vnd.oasis.opendocument.graphics-
template [OFFICE]
145application/vnd.oasis.opendocument.image [OFFICE]
146application/vnd.oasis.opendocument.image-
template [OFFICE]
147application/vnd.oasis.opendocument.presentation [OFFICE]
148application/vnd.oasis.opendocument.presentation-
template [OFFICE]
149application/vnd.oasis.opendocument.spreadsheet [OFFICE]
150application/vnd.oasis.opendocument.spreadsheet-
template [OFFICE]
151application/vnd.oasis.opendocument.text [OFFICE]
152application/vnd.oasis.opendocument.text-
template [OFFICE]
153application/vnd.oasis.opendocument.text-master [OFFICE]
154application/vnd.oasis.opendocument.text-web [OFFICE]
155application/javascript
text/javascript application/x-javascript [EXECUTABLE]
156application/x-shockwave-flash [MULTIMEDIA]
160audio/mp3 audio/mpeg [AUDIO]
161application/ogg audio/ogg video/ogg [MULTIMEDIA]
162image/x-bmp image/x-ms-bmp image/bmp [BITMAP]
166image/svg+xml [DRAWING]
168image/vnd.djvu [BITMAP]
170image/x-portable-pixmap [BITMAP]
175unknown/unknown application/octet-stream application/x-empty [UNKNOWN]
194 $this->typeFile =
$params[
'typeFile'];
195 $this->infoFile =
$params[
'infoFile'];
196 $this->xmlTypes =
$params[
'xmlTypes'];
197 $this->initCallback = isset(
$params[
'initCallback'] )
200 $this->detectCallback = isset(
$params[
'detectCallback'] )
203 $this->guessCallback = isset(
$params[
'guessCallback'] )
206 $this->extCallback = isset(
$params[
'extCallback'] )
209 $this->logger = isset(
$params[
'logger'] )
211 : new \Psr\Log\NullLogger();
216 protected function loadFiles() {
221 # Allow media handling extensions adding MIME-types and MIME-info
222 if ( $this->initCallback ) {
223 call_user_func( $this->initCallback, $this );
226 $types = self::$wellKnownTypes;
228 $mimeTypeFile = $this->typeFile;
229 if ( $mimeTypeFile ) {
230 if ( is_file( $mimeTypeFile ) && is_readable( $mimeTypeFile ) ) {
231 $this->logger->info( __METHOD__ .
": loading mime types from $mimeTypeFile\n" );
233 $types .= file_get_contents( $mimeTypeFile );
235 $this->logger->info( __METHOD__ .
": can't load mime types from $mimeTypeFile\n" );
238 $this->logger->info( __METHOD__ .
239 ": no mime types file defined, using built-ins only.\n" );
242 $types .=
"\n" . $this->extraTypes;
244 $types = str_replace( [
"\r\n",
"\n\r",
"\n\n",
"\r\r",
"\r" ],
"\n", $types );
245 $types = str_replace(
"\t",
" ", $types );
247 $this->mimetoExt = [];
248 $this->mExtToMime = [];
250 $lines = explode(
"\n", $types );
256 if ( strpos(
$s,
'#' ) === 0 ) {
260 $s = strtolower(
$s );
261 $i = strpos(
$s,
' ' );
263 if ( $i ===
false ) {
268 $ext = trim( substr(
$s, $i + 1 ) );
270 if ( empty(
$ext ) ) {
274 if ( !empty( $this->mimetoExt[
$mime] ) ) {
288 if ( !empty( $this->mExtToMime[
$e] ) ) {
289 $this->mExtToMime[
$e] .=
' ' .
$mime;
300 $mimeInfoFile = $this->infoFile;
302 $info = self::$wellKnownInfo;
304 if ( $mimeInfoFile ) {
305 if ( is_file( $mimeInfoFile ) && is_readable( $mimeInfoFile ) ) {
306 $this->logger->info( __METHOD__ .
": loading mime info from $mimeInfoFile\n" );
308 $info .= file_get_contents( $mimeInfoFile );
310 $this->logger->info( __METHOD__ .
": can't load mime info from $mimeInfoFile\n" );
313 $this->logger->info( __METHOD__ .
314 ": no mime info file defined, using built-ins only.\n" );
317 $info .=
"\n" . $this->extraInfo;
319 $info = str_replace( [
"\r\n",
"\n\r",
"\n\n",
"\r\r",
"\r" ],
"\n", $info );
320 $info = str_replace(
"\t",
" ", $info );
322 $this->mimeTypeAliases = [];
323 $this->mediaTypes = [];
325 $lines = explode(
"\n", $info );
331 if ( strpos(
$s,
'#' ) === 0 ) {
335 $s = strtolower(
$s );
336 $i = strpos(
$s,
' ' );
338 if ( $i ===
false ) {
342 # print "processing MIME INFO line $s<br>";
345 if ( preg_match(
'!\[\s*(\w+)\s*\]!',
$s, $match ) ) {
346 $s = preg_replace(
'!\[\s*(\w+)\s*\]!',
'',
$s );
347 $mtype = trim( strtoupper( $match[1] ) );
352 $m = explode(
' ',
$s );
354 if ( !isset( $this->mediaTypes[$mtype] ) ) {
355 $this->mediaTypes[$mtype] = [];
358 foreach ( $m as
$mime ) {
360 if ( empty(
$mime ) ) {
364 $this->mediaTypes[$mtype][] =
$mime;
367 if ( count( $m ) > 1 ) {
369 $mCount = count( $m );
370 for ( $i = 1; $i < $mCount; $i += 1 ) {
372 $this->mimeTypeAliases[
$mime] = $main;
378 public function setLogger( LoggerInterface $logger ) {
379 $this->logger = $logger;
389 $this->extraTypes .=
"\n" . $types;
398 public function addExtraInfo( $info ) {
399 $this->extraInfo .=
"\n" . $info;
410 public function getExtensionsForType(
$mime ) {
414 if ( isset( $this->mimetoExt[
$mime] ) ) {
415 return $this->mimetoExt[
$mime];
419 if ( isset( $this->mimeTypeAliases[
$mime] ) ) {
421 if ( isset( $this->mimetoExt[
$mime] ) ) {
422 return $this->mimetoExt[
$mime];
436 public function getTypesForExtension(
$ext ) {
439 $r = isset( $this->mExtToMime[
$ext] ) ? $this->mExtToMime[
$ext] :
null;
450 public function guessTypesForExtension(
$ext ) {
451 $m = $this->getTypesForExtension(
$ext );
452 if ( is_null( $m ) ) {
458 $m = preg_replace(
'/\s.*$/',
'', $m );
472 public function isMatchingExtension( $extension,
$mime ) {
473 $ext = $this->getExtensionsForType(
$mime );
481 $extension = strtolower( $extension );
482 return in_array( $extension,
$ext );
493 public function isPHPImageType(
$mime ) {
496 'image/gif',
'image/jpeg',
'image/png',
497 'image/x-bmp',
'image/xbm',
'image/tiff',
498 'image/jp2',
'image/jpeg2000',
'image/iff',
499 'image/xbm',
'image/x-xbitmap',
500 'image/vnd.wap.wbmp',
'image/vnd.xiff',
502 'application/x-shockwave-flash',
505 return in_array(
$mime, $types );
520 function isRecognizableExtension( $extension ) {
523 'gif',
'jpeg',
'jpg',
'png',
'swf',
'psd',
524 'bmp',
'tiff',
'tif',
'jpc',
'jp2',
525 'jpx',
'jb2',
'swc',
'iff',
'wbmp',
529 'djvu',
'ogx',
'ogg',
'ogv',
'oga',
'spx',
530 'mid',
'pdf',
'wmf',
'xcf',
'webm',
'mkv',
'mka',
536 return in_array( strtolower( $extension ), $types );
550 public function improveTypeFromExtension(
$mime,
$ext ) {
551 if (
$mime ===
'unknown/unknown' ) {
552 if ( $this->isRecognizableExtension(
$ext ) ) {
553 $this->logger->info( __METHOD__ .
': refusing to guess mime type for .' .
554 "$ext file, we should have recognized it\n" );
558 $mime = $this->guessTypesForExtension(
$ext );
560 } elseif (
$mime ===
'application/x-opc+zip' ) {
561 if ( $this->isMatchingExtension(
$ext,
$mime ) ) {
564 $mime = $this->guessTypesForExtension(
$ext );
566 $this->logger->info( __METHOD__ .
567 ": refusing to guess better type for $mime file, " .
568 ".$ext is not a known OPC extension.\n" );
569 $mime =
'application/zip';
571 } elseif (
$mime ===
'text/plain' && $this->findMediaType(
".$ext" ) ===
MEDIATYPE_TEXT ) {
576 $mime = $this->guessTypesForExtension(
$ext );
579 # Media handling extensions can improve the MIME detected
580 $callback = $this->extCallback;
585 if ( isset( $this->mimeTypeAliases[
$mime] ) ) {
589 $this->logger->info( __METHOD__ .
": improved mime type for .$ext: $mime\n" );
607 public function guessMimeType( $file,
$ext =
true ) {
609 $this->logger->info( __METHOD__ .
610 ": WARNING: use of the \$ext parameter is deprecated. " .
611 "Use improveTypeFromExtension(\$mime, \$ext) instead.\n" );
614 $mime = $this->doGuessMimeType( $file,
$ext );
617 $this->logger->info( __METHOD__ .
618 ": internal type detection failed for $file (.$ext)...\n" );
619 $mime = $this->detectMimeType( $file,
$ext );
622 if ( isset( $this->mimeTypeAliases[
$mime] ) ) {
626 $this->logger->info( __METHOD__ .
": guessed mime type of $file: $mime\n" );
640 private function doGuessMimeType( $file,
$ext ) {
642 MediaWiki\suppressWarnings();
643 $f = fopen( $file,
'rb' );
644 MediaWiki\restoreWarnings();
647 return 'unknown/unknown';
650 $fsize = filesize( $file );
651 if ( $fsize ===
false ) {
652 return 'unknown/unknown';
655 $head = fread( $f, 1024 );
656 $tailLength = min( 65558, $fsize );
657 if ( fseek( $f, -1 * $tailLength, SEEK_END ) === -1 ) {
658 throw new UnexpectedValueException(
659 "Seeking $tailLength bytes from EOF failed in " . __METHOD__ );
661 $tail = $tailLength ? fread( $f, $tailLength ) :
'';
664 $this->logger->info( __METHOD__ .
665 ": analyzing head and tail of $file for magic numbers.\n" );
670 'MThd' =>
'audio/midi',
671 'OggS' =>
'application/ogg',
675 "\x01\x00\x09\x00" =>
'application/x-msmetafile',
676 "\xd7\xcd\xc6\x9a" =>
'application/x-msmetafile',
677 '%PDF' =>
'application/pdf',
678 'gimp xcf' =>
'image/x-xcf',
681 'MZ' =>
'application/octet-stream',
682 "\xca\xfe\xba\xbe" =>
'application/octet-stream',
683 "\x7fELF" =>
'application/octet-stream',
686 foreach ( $headers as $magic => $candidate ) {
687 if ( strncmp( $head, $magic, strlen( $magic ) ) == 0 ) {
688 $this->logger->info( __METHOD__ .
689 ": magic header in $file recognized as $candidate\n" );
695 if ( strncmp( $head, pack(
"C4", 0x1a, 0x45, 0xdf, 0xa3 ), 4 ) == 0 ) {
696 $doctype = strpos( $head,
"\x42\x82" );
699 $data = substr( $head, $doctype + 3, 8 );
700 if ( strncmp( $data,
"matroska", 8 ) == 0 ) {
701 $this->logger->info( __METHOD__ .
": recognized file as video/x-matroska\n" );
702 return "video/x-matroska";
703 } elseif ( strncmp( $data,
"webm", 4 ) == 0 ) {
704 $this->logger->info( __METHOD__ .
": recognized file as video/webm\n" );
708 $this->logger->info( __METHOD__ .
": unknown EBML file\n" );
709 return "unknown/unknown";
713 if ( strncmp( $head,
"RIFF", 4 ) == 0 &&
714 strncmp( substr( $head, 8, 7 ),
"WEBPVP8", 7 ) == 0
716 $this->logger->info( __METHOD__ .
": recognized file as image/webp\n" );
732 if ( ( strpos( $head,
'<?php' ) !==
false ) ||
733 ( strpos( $head,
"<\x00?\x00p\x00h\x00p" ) !==
false ) ||
734 ( strpos( $head,
"<\x00?\x00 " ) !==
false ) ||
735 ( strpos( $head,
"<\x00?\x00\n" ) !==
false ) ||
736 ( strpos( $head,
"<\x00?\x00\t" ) !==
false ) ||
737 ( strpos( $head,
"<\x00?\x00=" ) !==
false ) ) {
739 $this->logger->info( __METHOD__ .
": recognized $file as application/x-php\n" );
740 return 'application/x-php';
747 if ( $xml->wellFormed ) {
748 $xmlTypes = $this->xmlTypes;
749 if ( isset( $xmlTypes[$xml->getRootElement()] ) ) {
750 return $xmlTypes[$xml->getRootElement()];
752 return 'application/xml';
762 if ( substr( $head, 0, 2 ) ==
"#!" ) {
763 $script_type =
"ASCII";
764 } elseif ( substr( $head, 0, 5 ) ==
"\xef\xbb\xbf#!" ) {
765 $script_type =
"UTF-8";
766 } elseif ( substr( $head, 0, 7 ) ==
"\xfe\xff\x00#\x00!" ) {
767 $script_type =
"UTF-16BE";
768 } elseif ( substr( $head, 0, 7 ) ==
"\xff\xfe#\x00!" ) {
769 $script_type =
"UTF-16LE";
772 if ( $script_type ) {
773 if ( $script_type !==
"UTF-8" && $script_type !==
"ASCII" ) {
775 $pack = [
'UTF-16BE' =>
'n*',
'UTF-16LE' =>
'v*' ];
776 $chars = unpack( $pack[$script_type], substr( $head, 2 ) );
778 foreach ( $chars as $codepoint ) {
779 if ( $codepoint < 128 ) {
780 $head .= chr( $codepoint );
789 if ( preg_match(
'%/?([^\s]+/)(\w+)%', $head, $match ) ) {
790 $mime =
"application/x-{$match[2]}";
791 $this->logger->info( __METHOD__ .
": shell script recognized as $mime\n" );
797 if ( strpos( $tail,
"PK\x05\x06" ) !==
false ) {
798 $this->logger->info( __METHOD__ .
": ZIP header present in $file\n" );
799 return $this->detectZipType( $head, $tail,
$ext );
802 MediaWiki\suppressWarnings();
803 $gis = getimagesize( $file );
804 MediaWiki\restoreWarnings();
806 if ( $gis && isset( $gis[
'mime'] ) ) {
807 $mime = $gis[
'mime'];
808 $this->logger->info( __METHOD__ .
": getimagesize detected $file as $mime\n" );
812 # Media handling extensions can guess the MIME by content
813 # It's intentionally here so that if core is wrong about a type (false positive),
814 # people will hopefully nag and submit patches :)
816 # Some strings by reference for performance - assuming well-behaved hooks
817 $callback = $this->guessCallback;
819 $callback( $this, $head, $tail, $file,
$mime );
838 function detectZipType(
$header, $tail =
null,
$ext =
false ) {
839 if (
$ext ) { # TODO:
remove $ext param
840 $this->logger->info( __METHOD__ .
841 ": WARNING: use of the \$ext parameter is deprecated. " .
842 "Use improveTypeFromExtension(\$mime, \$ext) instead.\n" );
845 $mime =
'application/zip';
855 'presentation-template',
857 'spreadsheet-template',
865 $types =
'(?:' . implode(
'|', $opendocTypes ) .
')';
866 $opendocRegex =
"/^mimetype(application\/vnd\.oasis\.opendocument\.$types)/";
868 $openxmlRegex =
"/^\[Content_Types\].xml/";
872 $this->logger->info( __METHOD__ .
": detected $mime from ZIP archive\n" );
873 } elseif ( preg_match( $openxmlRegex, substr(
$header, 30 ) ) ) {
874 $mime =
"application/x-opc+zip";
875 # TODO: remove the block below, as soon as improveTypeFromExtension is used everywhere
876 if (
$ext !==
true &&
$ext !==
false ) {
881 if ( $this->isMatchingExtension(
$ext,
$mime ) ) {
885 $mime = $this->guessTypesForExtension(
$ext );
887 $mime =
"application/zip";
890 $this->logger->info( __METHOD__ .
891 ": detected an Open Packaging Conventions archive: $mime\n" );
892 } elseif ( substr(
$header, 0, 8 ) ==
"\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1" &&
893 ( $headerpos = strpos( $tail,
"PK\x03\x04" ) ) !==
false &&
894 preg_match( $openxmlRegex, substr( $tail, $headerpos + 30 ) ) ) {
895 if ( substr(
$header, 512, 4 ) ==
"\xEC\xA5\xC1\x00" ) {
896 $mime =
"application/msword";
898 switch ( substr(
$header, 512, 6 ) ) {
899 case "\xEC\xA5\xC1\x00\x0E\x00":
900 case "\xEC\xA5\xC1\x00\x1C\x00":
901 case "\xEC\xA5\xC1\x00\x43\x00":
902 $mime =
"application/vnd.ms-powerpoint";
904 case "\xFD\xFF\xFF\xFF\x10\x00":
905 case "\xFD\xFF\xFF\xFF\x1F\x00":
906 case "\xFD\xFF\xFF\xFF\x22\x00":
907 case "\xFD\xFF\xFF\xFF\x23\x00":
908 case "\xFD\xFF\xFF\xFF\x28\x00":
909 case "\xFD\xFF\xFF\xFF\x29\x00":
910 case "\xFD\xFF\xFF\xFF\x10\x02":
911 case "\xFD\xFF\xFF\xFF\x1F\x02":
912 case "\xFD\xFF\xFF\xFF\x22\x02":
913 case "\xFD\xFF\xFF\xFF\x23\x02":
914 case "\xFD\xFF\xFF\xFF\x28\x02":
915 case "\xFD\xFF\xFF\xFF\x29\x02":
916 $mime =
"application/vnd.msexcel";
920 $this->logger->info( __METHOD__ .
921 ": detected a MS Office document with OPC trailer\n" );
923 $this->logger->info( __METHOD__ .
": unable to identify type of ZIP archive\n" );
945 private function detectMimeType( $file,
$ext =
true ) {
948 $this->logger->info( __METHOD__ .
949 ": WARNING: use of the \$ext parameter is deprecated. "
950 .
"Use improveTypeFromExtension(\$mime, \$ext) instead.\n" );
953 $callback = $this->detectCallback;
956 $m = $callback( $file );
957 } elseif ( function_exists(
"finfo_open" ) && function_exists(
"finfo_file" ) ) {
958 $mime_magic_resource = finfo_open( FILEINFO_MIME );
960 if ( $mime_magic_resource ) {
961 $m = finfo_file( $mime_magic_resource, $file );
962 finfo_close( $mime_magic_resource );
964 $this->logger->info( __METHOD__ .
965 ": finfo_open failed on " . FILEINFO_MIME .
"!\n" );
968 $this->logger->info( __METHOD__ .
": no magic mime detector found!\n" );
973 $m = preg_replace(
'![;, ].*$!',
'', $m ); # strip charset,
etc
975 $m = strtolower( $m );
977 if ( strpos( $m,
'unknown' ) !==
false ) {
980 $this->logger->info( __METHOD__ .
": magic mime type of $file: $m\n" );
986 if (
$ext ===
true ) {
987 $i = strrpos( $file,
'.' );
988 $ext = strtolower( $i ? substr( $file, $i + 1 ) :
'' );
991 if ( $this->isRecognizableExtension(
$ext ) ) {
992 $this->logger->info( __METHOD__ .
": refusing to guess mime type for .$ext file, "
993 .
"we should have recognized it\n" );
995 $m = $this->guessTypesForExtension(
$ext );
997 $this->logger->info( __METHOD__ .
": extension mime type of $file: $m\n" );
1004 $this->logger->info( __METHOD__ .
": failed to guess mime type for $file!\n" );
1005 return 'unknown/unknown';
1024 function getMediaType( $path =
null,
$mime =
null ) {
1025 if ( !
$mime && !$path ) {
1031 $mime = $this->guessMimeType( $path,
false );
1036 if (
$mime ==
'application/ogg' && file_exists( $path ) ) {
1039 $f = fopen( $path,
"rt" );
1043 $head = fread( $f, 256 );
1046 $head = str_replace(
'ffmpeg2theora',
'', strtolower( $head ) );
1049 if ( strpos( $head,
'theora' ) !==
false ) {
1051 } elseif ( strpos( $head,
'vorbis' ) !==
false ) {
1053 } elseif ( strpos( $head,
'flac' ) !==
false ) {
1055 } elseif ( strpos( $head,
'speex' ) !==
false ) {
1073 $i = strrpos( $path,
'.' );
1074 $e = strtolower( $i ? substr( $path, $i + 1 ) :
'' );
1077 $type = $this->findMediaType(
'.' .
$e );
1085 $i = strpos(
$mime,
'/' );
1086 if ( $i !==
false ) {
1087 $major = substr(
$mime, 0, $i );
1088 $type = $this->findMediaType( $major );
1112 function findMediaType( $extMime ) {
1113 if ( strpos( $extMime,
'.' ) === 0 ) {
1115 $m = $this->getTypesForExtension( substr( $extMime, 1 ) );
1120 $m = explode(
' ', $m );
1123 if ( isset( $this->mimeTypeAliases[$extMime] ) ) {
1124 $extMime = $this->mimeTypeAliases[$extMime];
1130 foreach ( $m as
$mime ) {
1131 foreach ( $this->mediaTypes as
$type => $codes ) {
1132 if ( in_array(
$mime, $codes,
true ) ) {
1150 public function getIEMimeTypes( $fileName, $chunk, $proposed ) {
1151 $ca = $this->getIEContentAnalyzer();
1152 return $ca->getRealMimesFromData( $fileName, $chunk, $proposed );
1160 protected function getIEContentAnalyzer() {
1161 if ( is_null( $this->IEAnalyzer ) ) {
1164 return $this->IEAnalyzer;
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
This class simulates Microsoft Internet Explorer's terribly broken and insecure MIME type detection a...
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add etc
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
the array() calling protocol came about after MediaWiki 1.4rc1.
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
for adding new MIME info to the list Use $mimeMagic addExtraTypes( $stringOfTypes)
returning false will NOT prevent logging $e
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
const MEDIATYPE_MULTIMEDIA
if( $ext=='php'|| $ext=='php5') $mime