Minor followup to r63425 and r63428
authorSam Reed <reedy@users.mediawiki.org>
Tue, 9 Mar 2010 11:52:43 +0000 (11:52 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Tue, 9 Mar 2010 11:52:43 +0000 (11:52 +0000)
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
includes/api/ApiQueryAllmessages.php

index aee70ac..ab1d627 100644 (file)
@@ -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
                }
        }
index 114bf7f..a815169 100644 (file)
@@ -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
                }
        }