Revert r36816 for the moment (Add $wgAdditionalXMLTypes, an array of XML mimetypes...
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 2 Jul 2008 23:07:39 +0000 (23:07 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 2 Jul 2008 23:07:39 +0000 (23:07 +0000)
I very much like the idea of making this extensible, but the current implementation has a couple problems. I'd recommend addresses the following:
* The format of the array isn't documented; it has neither examples nor a description of the content format in its comment. If I wanted to add something to it, I wouldn't know what the result should look like without looking up the code.
* Rather than "additional" types, it might be best to simply list *all* the types we recognize in the default array -- then it can be modified and extended in local configuration. This would have the following benefits:
** Allows modifying existing types
** Defaults are an example of format, making the structure self-documenting
** Avoids code duplication -- we only have to check one array, not two, and don't have to worry about their formats getting out of sync.

RELEASE-NOTES
includes/DefaultSettings.php
includes/MimeMagic.php

index 735b2b6..a6e1dd8 100644 (file)
@@ -64,8 +64,6 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   previously it was choosen based on $wgParserCacheType
 * $wgExtensionAliasesFiles option to simplify adding aliases to special pages
   provided by extensions, in a similar way to $wgExtensionMessagesFiles
-* Added $wgAdditionalXMLTypes, an array of XML mimetypes we can check for
-  with MimeMagic.
 
 === New features in 1.13 ===
 
index 6abdd95..6aae1d6 100644 (file)
@@ -366,11 +366,6 @@ $wgMimeDetectorCommand= NULL; # use internal mime_content_type function, availab
  */
 $wgTrivialMimeDetection= false;
 
-/**
- * Additional XML types we can allow via mime-detection.
- */
-$wgAdditionalXMLTypes = array();
-
 /**
  * To set 'pretty' URL paths for actions other than
  * plain page views, add to this array. For instance:
index aa495f6..01d33c7 100644 (file)
@@ -457,7 +457,6 @@ class MimeMagic {
                 */
                $xml = new XmlTypeCheck( $file );
                if( $xml->wellFormed ) {
-                       global $wgAdditionalXMLTypes;
                        $types = array(
                                'http://www.w3.org/2000/svg:svg'                => 'image/svg+xml',
                                'svg'                                           => 'image/svg+xml',
@@ -465,12 +464,11 @@ class MimeMagic {
                                'http://www.w3.org/1999/xhtml:html'             => 'text/html', // application/xhtml+xml?
                                'html'                                          => 'text/html', // application/xhtml+xml?
                        );
-                       
                        if( isset( $types[$xml->rootElement] ) ) {
-                               return $types[$xml->rootElement];
-                       } elseif( isset( $wgAdditionalXMLTypes[$xml->rootElement] ) ) {
-                               return $wgAdditionalXMLTypes[$xml->rootElement];
+                               $mime = $types[$xml->rootElement];
+                               return $mime;
                        } else {
+                               /// Fixme -- this would be the place to allow additional XML type checks
                                return 'application/xml';
                        }
                }