r70607 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70606‎ | r70607 | r70608 >
Date:23:40, 6 August 2010
Author:siebrand
Status:deferred
Tags:
Comment:
Remove version checks for some outdated versions of MediaWiki (1.11 and earlier).
Modified paths:
  • /trunk/extensions/ContactPageFundraiser/SpecialContact.php (modified) (history)
  • /trunk/extensions/ContributionScores/ContributionScores.php (modified) (history)
  • /trunk/extensions/ContributionScores/ContributionScores_body.php (modified) (history)
  • /trunk/extensions/Contributors/Contributors.page.php (modified) (history)
  • /trunk/extensions/CountEdits/CountEdits.page.php (modified) (history)
  • /trunk/extensions/DynamicPageList/DynamicPageListInclude.php (modified) (history)
  • /trunk/extensions/EmbedVideo/EmbedVideo.hooks.php (modified) (history)
  • /trunk/extensions/EmbedVideo/EmbedVideo.php (modified) (history)
  • /trunk/extensions/GoogleMaps/GoogleMaps.php (modified) (history)
  • /trunk/extensions/LabeledSectionTransclusion/lst.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/NewsChannel/NewsChannel_body.php (modified) (history)
  • /trunk/extensions/SmoothGallery/SmoothGalleryClass.php (modified) (history)
  • /trunk/extensions/StalePages/StalePages_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ContributionScores/ContributionScores_body.php
@@ -138,10 +138,9 @@
139139 }
140140
141141 function execute( $par ) {
142 - global $wgRequest, $wgVersion, $wgOut, $wgHooks;
 142+ global $wgRequest, $wgOut, $wgHooks;
143143
144 - if( version_compare( $wgVersion, '1.11', '>=' ) )
145 - wfLoadExtensionMessages( 'ContributionScores' );
 144+ wfLoadExtensionMessages( 'ContributionScores' );
146145
147146 $this->setHeaders();
148147
Index: trunk/extensions/ContributionScores/ContributionScores.php
@@ -33,28 +33,13 @@
3434 if( version_compare( $wgVersion, '1.13', '>=' ) ) {
3535 $wgExtensionMessagesFiles['ContributionScores'] = CONTRIBUTIONSCORES_PATH . '/ContributionScores.i18n.php';
3636 $wgExtensionAliasesFiles['ContributionScores'] = CONTRIBUTIONSCORES_PATH . '/ContributionScores.alias.php';
37 -} else if( version_compare( $wgVersion, '1.11', '>=' ) ) {
3837 $wgExtensionMessagesFiles['ContributionScores'] = CONTRIBUTIONSCORES_PATH . '/ContributionScores.i18n.php';
39 -} else {
40 - $wgExtensionFunctions[] = 'efContributionScores_AddMessages';
4138 }
4239
4340 $wgHooks['LanguageGetMagic'][] = 'efContributionScores_LanguageGetMagic';
4441
4542 $wgHooks['ParserFirstCallInit'][] = 'efContributionScores_Setup';
4643
47 -///Message Cache population for versions that did not support $wgExtensionFunctions
48 -function efContributionScores_AddMessages() {
49 - global $wgMessageCache;
50 -
51 - #Add Messages
52 - require( CONTRIBUTIONSCORES_PATH . '/ContributionScores.i18n.php' );
53 - foreach( $messages as $key => $value ) {
54 - $wgMessageCache->addMessages( $messages[$key], $key );
55 - }
56 - return true;
57 -}
58 -
5944 function efContributionScores_Setup( &$parser ) {
6045 $parser->setFunctionHook( 'cscore', 'efContributionScores_Render' );
6146 return true;
@@ -66,10 +51,9 @@
6752 }
6853
6954 function efContributionScores_Render(&$parser, $usertext, $metric='score') {
70 - global $wgContribScoreDisableCache, $wgVersion;
 55+ global $wgContribScoreDisableCache;
7156
72 - if( version_compare( $wgVersion, '1.11', '>=' ) )
73 - wfLoadExtensionMessages( 'ContributionScores' );
 57+ wfLoadExtensionMessages( 'ContributionScores' );
7458
7559 $output = "";
7660
Index: trunk/extensions/SmoothGallery/SmoothGalleryClass.php
@@ -195,11 +195,8 @@
196196 continue;
197197 }
198198
199 - if ( version_compare( $wgVersion, "1.11", '<' ) ) {
200 - $plain_gallery->add( $image["image_object"], $image["description"] ); // TODO: use text
201 - } else {
202 - $plain_gallery->add( $image["image_object"]->getTitle(), $image["description"] ); // TODO: use text
203 - }
 199+ $plain_gallery->add( $image["image_object"]->getTitle(), $image["description"] ); // TODO: use text
 200+
204201 $i++;
205202 }
206203
Index: trunk/extensions/NewsChannel/NewsChannel_body.php
@@ -37,16 +37,10 @@
3838 * @param string $par Custom parameters.
3939 */
4040 function execute( $par ) {
41 - global $wgRequest, $wgVersion, $wgOut, $wgNewsChannelCategory, $wgNewsChannelDefaultItems;
 41+ global $wgRequest, $wgOut, $wgNewsChannelCategory, $wgNewsChannelDefaultItems;
4242
4343 wfLoadExtensionMessages( 'NewsChannel' );
4444
45 - if( version_compare( $wgVersion, '1.8', '<' ) === true ) {
46 - $wgOut->showErrorPage( "Error: Upgrade required", "The News Channel extension can't work " .
47 - "on MediaWiki older than 1.8. Please, upgrade." );
48 - return;
49 - }
50 -
5145 if( $wgNewsChannelCategory == '' || $wgNewsChannelCategory == null ) {
5246 $wgOut->showErrorPage( "Error: Misconfiguration", "Main category containing news articles " .
5347 "was not defined for News Channel extension. Please, define it." );
Index: trunk/extensions/GoogleMaps/GoogleMaps.php
@@ -26,28 +26,6 @@
2727 require( 'extensions/GoogleMaps/SpecialGoogleMapsKML.php' );
2828 require( 'extensions/GoogleMaps/GoogleMaps.body.php' );
2929
30 -/**
31 - * This function is for rendering a <googlemap> tag on MW 1.5.
32 - * It cannot be an object function. (Compare to the render16 function
33 - * of the GoogleMaps class.)
34 - *
35 - * @param $pContent string - the content of the <googlemap> tag
36 - * @param $pArgv array - an array of attribute name/value pairs for the
37 - * tag
38 - *
39 - * @return string - the HTML string to output for the <googlemap> tag
40 - **/
41 -function wfGoogleMaps_Render15 ( $pContent, $pArgv ) {
42 - global $wgGoogleMaps, $wgParser;
43 - // get the global parser and pass through to the main render function
44 - return $wgGoogleMaps->render( $pContent, $pArgv, $wgParser, $wgParser );
45 -}
46 -
47 -function wfGoogleMaps_RenderKmlLink15 ( $pContent, $pArgv ) {
48 - global $wgGoogleMaps;
49 - return $wgGoogleMaps->renderKmlLink( $pContent, $pArgv );
50 -}
51 -
5230 function wfGoogleMaps_CommentJS(&$pParser, &$pText) {
5331 global $wgGoogleMaps;
5432 return $wgGoogleMaps->commentJS($pParser, $pText);
@@ -64,7 +42,7 @@
6543 global $wgGoogleMapsKey, $wgGoogleMapsKeys, $wgGoogleMapsDisableEditorsMap, $wgGoogleMapsEnablePaths,
6644 $wgGoogleMapsDefaults, $wgGoogleMapsMessages, $wgGoogleMapsCustomMessages, $wgGoogleMapsUrlPath,
6745 $wgXhtmlNamespaces, $wgGoogleMapsTemplateVariables, $wgJsMimeType, $wgLanguageCode, $wgContLang,
68 - $wgParser, $wgProxyKey, $wgVersion, $wgGoogleMaps, $wgHooks, $wgScriptPath, $wgSpecialPages,
 46+ $wgParser, $wgProxyKey, $wgGoogleMaps, $wgHooks, $wgScriptPath, $wgSpecialPages,
6947 $wgTitle;
7048 // set up some default values for the various extension configuration parameters
7149 // to keep from getting PHP notices if running in strict mode
@@ -118,11 +96,7 @@
11997
12098 // add the google mime types
12199 $magic = null;
122 - if( version_compare( $wgVersion, "1.8" ) >= 0 ) {
123 - $magic = MimeMagic::singleton( );
124 - } else {
125 - $magic = wfGetMimeMagic( );
126 - }
 100+ $magic = MimeMagic::singleton( );
127101 $magic->mExtToMime['kml'] = 'application/vnd.google-earth.kml+xml';
128102 $magic->mExtToMime['kmz'] = 'application/vnd.google-earth.kmz';
129103
@@ -142,16 +116,13 @@
143117 $wgTitle );
144118
145119 // This hook will add the interactive editing map to the article edit page.
146 - // This hook was introduced in MW 1.6
147120 $editHook = array( $wgGoogleMaps, 'editForm' );
148 - if( version_compare( $wgVersion, "1.6" ) >= 0 ) {
149 - if( !$wgGoogleMapsDisableEditorsMap ) {
150 - if( isset( $wgHooks['EditPage::showEditForm:initial'] )
151 - && is_array( $wgHooks['EditPage::showEditForm:initial'] ) ) {
152 - array_unshift( $wgHooks['EditPage::showEditForm:initial'], $editHook );
153 - } else {
154 - $wgHooks['EditPage::showEditForm:initial'] = array( $editHook );
155 - }
 121+ if( !$wgGoogleMapsDisableEditorsMap ) {
 122+ if( isset( $wgHooks['EditPage::showEditForm:initial'] )
 123+ && is_array( $wgHooks['EditPage::showEditForm:initial'] ) ) {
 124+ array_unshift( $wgHooks['EditPage::showEditForm:initial'], $editHook );
 125+ } else {
 126+ $wgHooks['EditPage::showEditForm:initial'] = array( $editHook );
156127 }
157128 }
158129
@@ -167,13 +138,8 @@
168139 // This hook will be called any time the parser encounters a <googlemap>
169140 // tag in an article. This will render the actual Google map code in
170141 // the article.
171 - if( version_compare( $wgVersion, "1.6" ) >= 0 ) {
172 - $wgParser->setHook( 'googlemap', array( $wgGoogleMaps, 'render16' ) );
173 - $wgParser->setHook( 'googlemapkml', array( $wgGoogleMaps, 'renderKmlLink' ) );
174 - } else {
175 - $wgParser->setHook( 'googlemap', 'wfGoogleMaps_Render15' );
176 - $wgParser->setHook( 'googlemapkml', 'wfGoogleMaps_RenderKmlLink15' );
177 - }
 142+ $wgParser->setHook( 'googlemap', array( $wgGoogleMaps, 'render16' ) );
 143+ $wgParser->setHook( 'googlemapkml', array( $wgGoogleMaps, 'renderKmlLink' ) );
178144
179145 // Set up the special page
180146 $wgSpecialPages['GoogleMapsKML'] = array('GoogleMapsKML', 'GoogleMapsKML');
Index: trunk/extensions/EmbedVideo/EmbedVideo.php
@@ -33,13 +33,5 @@
3434 $wgExtensionMessagesFiles['embedvideo'] = $dir . 'EmbedVideo.i18n.php';
3535
3636 $wgHooks['ParserFirstCallInit'][] = "EmbedVideo::setup";
37 -if ( version_compare( $wgVersion, '1.7', '<' ) ) {
38 - # Hack solution to resolve 1.6 array parameter nullification for hook args
39 - function wfEmbedVideoLanguageGetMagic( &$magicWords ) {
40 - EmbedVideo::parserFunctionMagic( $magicWords );
41 - return true;
42 - }
43 - $wgHooks['LanguageGetMagic'][] = 'wfEmbedVideoLanguageGetMagic';
44 -} else {
45 - $wgHooks['LanguageGetMagic'][] = 'EmbedVideo::parserFunctionMagic';
46 -}
 37+$wgHooks['LanguageGetMagic'][] = 'EmbedVideo::parserFunctionMagic';
 38+
Index: trunk/extensions/EmbedVideo/EmbedVideo.hooks.php
@@ -15,9 +15,7 @@
1616 public static function setup() {
1717 # Setup parser hooks. ev is the primary hook, evp is supported for
1818 # legacy purposes
19 - global $wgVersion;
20 -
21 - $prefix = version_compare( $wgVersion, '1.7', '<' ) ? '#' : '';
 19+ $prefix = '';
2220 EmbedVideo::addMagicWord( $prefix, "ev", "EmbedVideo::parserFunction_ev" );
2321 EmbedVideo::addMagicWord( $prefix, "evp", "EmbedVideo::parserFunction_evp" );
2422
Index: trunk/extensions/CountEdits/CountEdits.page.php
@@ -62,11 +62,9 @@
6363 }
6464
6565 function countEditsReal( $id, $text = false ) {
66 - global $wgVersion;
6766 $dbr = wfGetDB( DB_SLAVE );
68 - # MediaWiki 1.9.x has a user.user_editcount column we can use,
69 - # but this is not useful for older versions or anon. checks
70 - if( $text === false && version_compare( $wgVersion, '1.9alpha', '>=' ) ) {
 67+
 68+ if( $text === false ) {
7169 $conds = array( 'user_id' => $id );
7270 return $dbr->selectField( 'user', 'user_editcount', $conds, 'CountEdits::countEditsReal' );
7371 } else {
Index: trunk/extensions/ContactPageFundraiser/SpecialContact.php
@@ -325,11 +325,7 @@
326326
327327 wfDebug( "$fname: sending mail from ".$from->toString()." to ".$to->toString()." replyto ".($replyto==null?'-/-':$replyto->toString())."\n" );
328328
329 - #HACK: in MW 1.9, replyto must be a string, in MW 1.10 it must be an object!
330 - $ver = preg_replace( '![^\d._+]!', '', $GLOBALS['wgVersion'] );
331 - $replyaddr = $replyto == null
332 - ? null : version_compare( $ver, '1.10', '<' )
333 - ? $replyto->toString() : $replyto;
 329+ $replyaddr = $replyto == null ? null : $replyto;
334330
335331 $mailResult = userMailer( $to, $from, $subject, $this->text, $replyaddr );
336332
Index: trunk/extensions/StalePages/StalePages_body.php
@@ -24,9 +24,7 @@
2525 }
2626
2727 function execute( $parameters ) {
28 - global $wgVersion;
29 - if( version_compare( $wgVersion, '1.11', '>=' ) )
30 - wfLoadExtensionMessages( 'Stalepages' );
 28+ wfLoadExtensionMessages( 'Stalepages' );
3129
3230 $this->setHeaders();
3331 list( $limit, $offset ) = wfCheckLimits();
Index: trunk/extensions/LabeledSectionTransclusion/lst.php
@@ -137,13 +137,6 @@
138138 $text = str_replace('</section>', '', $text);
139139
140140 if (self::open_($parser, $part1)) {
141 - //Handle recursion here, so we can break cycles.
142 - global $wgVersion;
143 - if( version_compare( $wgVersion, "1.9" ) < 0 ) {
144 - $text = $parser->replaceVariables($text);
145 - self::close_($parser, $part1);
146 - }
147 -
148141 //Try to get edit sections correct by munging around the parser's guts.
149142 return array($text, 'title'=>$title, 'replaceHeadings'=>true,
150143 'headingOffset'=>$skiphead, 'noparse'=>false, 'noargs'=>false);
Index: trunk/extensions/Contributors/Contributors.page.php
@@ -178,10 +178,8 @@
179179 * @return array
180180 */
181181 protected static function getConditions($title) {
182 - global $wgVersion;
183182 $conds['rev_page'] = $title->getArticleId();
184 - if( version_compare( $wgVersion, '1.11alpha', '>=' ) )
185 - $conds[] = 'rev_deleted & ' . Revision::DELETED_USER . ' = 0';
 183+ $conds[] = 'rev_deleted & ' . Revision::DELETED_USER . ' = 0';
186184 return $conds;
187185 }
188186
Index: trunk/extensions/MetavidWiki/includes/MV_GlobalFunctions.php
@@ -433,30 +433,9 @@
434434 * Function based on version in ContributionScores extension
435435 */
436436 function mvfInitMessages() {
437 - global $wgVersion, $wgExtensionFunctions;
438 - if ( version_compare( $wgVersion, '1.11', '>=' ) ) {
439 - wfLoadExtensionMessages( 'MetavidWiki' );
440 - } else {
441 - $wgExtensionFunctions[] = 'sffLoadMessagesManually';
442 - }
 437+ wfLoadExtensionMessages( 'MetavidWiki' );
443438 }
444439
445 -/**
446 - * Setting of message cache for versions of MediaWiki that do not support
447 - * wgExtensionFunctions - based on ceContributionScores() in
448 - * ContributionScores extension
449 - */
450 -function sffLoadMessagesManually() {
451 - global $mvgIP, $wgMessageCache;
452 -
453 - # add messages
454 - require( $mvgIP . '/languages/MV_Messages.php' );
455 - global $messages;
456 - foreach ( $messages as $key => $value ) {
457 - $wgMessageCache->addMessages( $messages[$key], $key );
458 - }
459 -}
460 -
461440 /*
462441 * Utility functions:
463442 */
Index: trunk/extensions/DynamicPageList/DynamicPageListInclude.php
@@ -135,8 +135,6 @@
136136 $recursionCheck = true, $maxLength = - 1, $link = '',
137137 $trim = false, $skipPattern = array()
138138 ) {
139 - global $wgVersion;
140 -
141139 // if someone tries something like<section begin=blah>lst only</section>
142140 // text, may as well do the right thing.
143141 $text = str_replace( '</section>', '', $text );
@@ -147,10 +145,8 @@
148146 }
149147
150148 if ( self::open( $parser, $part1 ) ) {
151 - // Handle recursion here, so we can break cycles. Although we can't do
152 - // feature detection here, r18473 was only a few weeks before the
153 - // release, so this is close enough.
154 - if ( version_compare( $wgVersion, '1.9' ) < 0 || $recursionCheck == false ) {
 149+ // Handle recursion here, so we can break cycles.
 150+ if ( $recursionCheck == false ) {
155151 $text = $parser->preprocess( $text, $parser->mTitle, $parser->mOptions );
156152 self::close( $parser, $part1 );
157153 }

Status & tagging log