From: Sam Reed Date: Tue, 9 Mar 2010 11:52:43 +0000 (+0000) Subject: Minor followup to r63425 and r63428 X-Git-Tag: 1.31.0-rc.0~37503 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=dc4786f86cabc5dd0912c66f84c6a05b9a1b88c3;p=lhc%2Fweb%2Fwiklou.git Minor followup to r63425 and r63428 Set $oldLang to null, and only reset if !is_null( $oldLang ) Also, only change language on ApiQueryAllmessages if wanted language != current language --- diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index aee70acff9..ab1d627af2 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -55,6 +55,7 @@ class ApiParse extends ApiBase { global $wgParser, $wgUser, $wgTitle, $wgEnableParserCache, $wgLang; //Current unncessary, code to act as a safeguard against any change in current behaviour of uselang breaks + $oldLang = null; if ( isset( $params['uselang'] ) && $params['uselang'] != $wgLang->getCode() ) { $oldLang = $wgLang; //Backup wgLang $wgLang = Language::factory( $params['uselang'] ); @@ -212,7 +213,7 @@ class ApiParse extends ApiBase { $this->setIndexedTagNames( $result_array, $result_mapping ); $result->addValue( null, $this->getModuleName(), $result_array ); - if ( isset( $params['uselang'] ) ) { + if ( !is_null( $oldLang ) ) { $wgLang = $oldLang; //Reset $wgLang to $oldLang } } diff --git a/includes/api/ApiQueryAllmessages.php b/includes/api/ApiQueryAllmessages.php index 114bf7f742..a8151697f0 100644 --- a/includes/api/ApiQueryAllmessages.php +++ b/includes/api/ApiQueryAllmessages.php @@ -44,7 +44,8 @@ class ApiQueryAllmessages extends ApiQueryBase { global $wgLang; - if ( !is_null( $params['lang'] ) ) { + $oldLang = null; + if ( !is_null( $params['lang'] ) && $params['lang'] != $wgLang->getCode() ) { $oldLang = $wgLang; //Keep $wgLang for restore later $wgLang = Language::factory( $params['lang'] ); } @@ -123,7 +124,7 @@ class ApiQueryAllmessages extends ApiQueryBase { } $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'message' ); - if ( !is_null( $params['lang'] ) ) { + if ( !is_null( $oldLang ) ) { $wgLang = $oldLang; //Restore $oldLang } }