r96971 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96970‎ | r96971 | r96972 >
Date:14:32, 13 September 2011
Author:jeroendedauw
Status:ok
Tags:
Comment:
added getLang method for better compat w/ 1.18 and later
Modified paths:
  • /trunk/extensions/UploadWizard/includes/specials/SpecialUploadWizard.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/includes/specials/SpecialUploadWizard.php
@@ -49,12 +49,25 @@
5050 }
5151
5252 /**
 53+ * Shortcut to get user's language.
 54+ * This overrides the getLang method of Specialpage added in MediaWiki 1.18,
 55+ * and returns $wgLang for older versions.
 56+ *
 57+ * @since 0.1
 58+ *
 59+ * @return Language
 60+ */
 61+ public function getLang() {
 62+ return version_compare( $GLOBALS['wgVersion'], '1.18', '>=' ) ? parent::getLang() : $GLOBALS['wgLang'];
 63+ }
 64+
 65+ /**
5366 * Replaces default execute method
5467 * Checks whether uploading enabled, user permissions okay,
5568 * @param $subPage, e.g. the "foo" in Special:UploadWizard/foo.
5669 */
5770 public function execute( $subPage ) {
58 - global $wgRequest, $wgLang, $wgUser;
 71+ global $wgRequest, $wgUser;
5972
6073 // side effects: if we can't upload, will print error page to wgOut
6174 // and return false
@@ -185,8 +198,7 @@
186199
187200 if ( trim( $pageName ) != '' ) {
188201 if ( is_null( $langCode ) ) {
189 - global $wgLang;
190 - $langCode = $wgLang->getCode();
 202+ $langCode = $this->getLang()->getCode();
191203 }
192204
193205 $page = Title::newFromText( str_replace( '$1', $langCode, $pageName ) );

Status & tagging log