r63463 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63462‎ | r63463 | r63464 >
Date:11:52, 9 March 2010
Author:reedy
Status:ok
Tags:
Comment:
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
Modified paths:
  • /trunk/phase3/includes/api/ApiParse.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllmessages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiParse.php
@@ -55,6 +55,7 @@
5656 global $wgParser, $wgUser, $wgTitle, $wgEnableParserCache, $wgLang;
5757
5858 //Current unncessary, code to act as a safeguard against any change in current behaviour of uselang breaks
 59+ $oldLang = null;
5960 if ( isset( $params['uselang'] ) && $params['uselang'] != $wgLang->getCode() ) {
6061 $oldLang = $wgLang; //Backup wgLang
6162 $wgLang = Language::factory( $params['uselang'] );
@@ -212,7 +213,7 @@
213214 $this->setIndexedTagNames( $result_array, $result_mapping );
214215 $result->addValue( null, $this->getModuleName(), $result_array );
215216
216 - if ( isset( $params['uselang'] ) ) {
 217+ if ( !is_null( $oldLang ) ) {
217218 $wgLang = $oldLang; //Reset $wgLang to $oldLang
218219 }
219220 }
Index: trunk/phase3/includes/api/ApiQueryAllmessages.php
@@ -44,7 +44,8 @@
4545
4646 global $wgLang;
4747
48 - if ( !is_null( $params['lang'] ) ) {
 48+ $oldLang = null;
 49+ if ( !is_null( $params['lang'] ) && $params['lang'] != $wgLang->getCode() ) {
4950 $oldLang = $wgLang; //Keep $wgLang for restore later
5051 $wgLang = Language::factory( $params['lang'] );
5152 }
@@ -123,7 +124,7 @@
124125 }
125126 $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'message' );
126127
127 - if ( !is_null( $params['lang'] ) ) {
 128+ if ( !is_null( $oldLang ) ) {
128129 $wgLang = $oldLang; //Restore $oldLang
129130 }
130131 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r63425Restore $wgLang in ApiQueryAllmessages if changed during executionreedy22:26, 8 March 2010
r63428* (bug 22764) uselang parameter for action=parse...reedy22:32, 8 March 2010

Status & tagging log