From dc4786f86cabc5dd0912c66f84c6a05b9a1b88c3 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Tue, 9 Mar 2010 11:52:43 +0000 Subject: [PATCH] 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 --- includes/api/ApiParse.php | 3 ++- includes/api/ApiQueryAllmessages.php | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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 } } -- 2.20.1