r36958 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36957‎ | r36958 | r36959 >
Date:23:07, 2 July 2008
Author:brion
Status:old
Tags:
Comment:
Revert r36816 for the moment (Add $wgAdditionalXMLTypes, an array of XML mimetypes we can check for with MimeMagic.)

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.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/MimeMagic.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/MimeMagic.php
@@ -457,7 +457,6 @@
458458 */
459459 $xml = new XmlTypeCheck( $file );
460460 if( $xml->wellFormed ) {
461 - global $wgAdditionalXMLTypes;
462461 $types = array(
463462 'http://www.w3.org/2000/svg:svg' => 'image/svg+xml',
464463 'svg' => 'image/svg+xml',
@@ -465,12 +464,11 @@
466465 'http://www.w3.org/1999/xhtml:html' => 'text/html', // application/xhtml+xml?
467466 'html' => 'text/html', // application/xhtml+xml?
468467 );
469 -
470468 if( isset( $types[$xml->rootElement] ) ) {
471 - return $types[$xml->rootElement];
472 - } elseif( isset( $wgAdditionalXMLTypes[$xml->rootElement] ) ) {
473 - return $wgAdditionalXMLTypes[$xml->rootElement];
 469+ $mime = $types[$xml->rootElement];
 470+ return $mime;
474471 } else {
 472+ /// Fixme -- this would be the place to allow additional XML type checks
475473 return 'application/xml';
476474 }
477475 }
Index: trunk/phase3/includes/DefaultSettings.php
@@ -367,11 +367,6 @@
368368 $wgTrivialMimeDetection= false;
369369
370370 /**
371 - * Additional XML types we can allow via mime-detection.
372 - */
373 -$wgAdditionalXMLTypes = array();
374 -
375 -/**
376371 * To set 'pretty' URL paths for actions other than
377372 * plain page views, add to this array. For instance:
378373 * 'edit' => "$wgScriptPath/edit/$1"
Index: trunk/phase3/RELEASE-NOTES
@@ -64,8 +64,6 @@
6565 previously it was choosen based on $wgParserCacheType
6666 * $wgExtensionAliasesFiles option to simplify adding aliases to special pages
6767 provided by extensions, in a similar way to $wgExtensionMessagesFiles
68 -* Added $wgAdditionalXMLTypes, an array of XML mimetypes we can check for
69 - with MimeMagic.
7068
7169 === New features in 1.13 ===
7270

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r36816Add $wgAdditionalXMLTypes, an array of XML mimetypes we can check for with Mi...demon14:46, 30 June 2008

Status & tagging log