r63428 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63427‎ | r63428 | r63429 >
Date:22:32, 8 March 2010
Author:reedy
Status:ok
Tags:
Comment:
* (bug 22764) uselang parameter for action=parse

Also add a few full stops to normalise format of Params
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiParse.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiParse.php
@@ -52,7 +52,13 @@
5353
5454 // The parser needs $wgTitle to be set, apparently the
5555 // $title parameter in Parser::parse isn't enough *sigh*
56 - global $wgParser, $wgUser, $wgTitle, $wgEnableParserCache;
 56+ global $wgParser, $wgUser, $wgTitle, $wgEnableParserCache, $wgLang;
 57+
 58+ if ( isset( $params['uselang'] ) && $params['uselang'] != $wgLang->getCode() ) {
 59+ $oldLang = $wgLang; //Backup wgLang
 60+ $wgLang = Language::factory( $params['uselang'] );
 61+ }
 62+
5763 $popts = new ParserOptions();
5864 $popts->setTidy( true );
5965 $popts->enableLimitReport();
@@ -204,6 +210,10 @@
205211 );
206212 $this->setIndexedTagNames( $result_array, $result_mapping );
207213 $result->addValue( null, $this->getModuleName(), $result_array );
 214+
 215+ if ( isset( $params['uselang'] ) ) {
 216+ $wgLang = $oldLang; //Reset $wgLang to $oldLang
 217+ }
208218 }
209219
210220 private function formatLangLinks( $links ) {
@@ -299,14 +309,14 @@
300310
301311 public function getParamDescription() {
302312 return array(
303 - 'text' => 'Wikitext to parse',
304 - 'summary' => 'Summary to parse',
305 - 'redirects' => 'If the page parameter is set to a redirect, resolve it',
306 - 'title' => 'Title of page the text belongs to',
307 - 'page' => 'Parse the content of this page. Cannot be used together with text and title',
308 - 'oldid' => 'Parse the content of this revision. Overrides page',
 313+ 'text' => 'Wikitext to parse.',
 314+ 'summary' => 'Summary to parse.',
 315+ 'redirects' => 'If the page parameter is set to a redirect, resolve it.',
 316+ 'title' => 'Title of page the text belongs to.',
 317+ 'page' => 'Parse the content of this page. Cannot be used together with text and title.',
 318+ 'oldid' => 'Parse the content of this revision. Overrides page.',
309319 'prop' => array( 'Which pieces of information to get.',
310 - 'NOTE: Section tree is only generated if there are more than 4 sections, or if the __TOC__ keyword is present'
 320+ 'NOTE: Section tree is only generated if there are more than 4 sections, or if the __TOC__ keyword is present.'
311321 ),
312322 'pst' => array( 'Do a pre-save transform on the input before parsing it.',
313323 'Ignored if page or oldid is used.'
@@ -314,6 +324,7 @@
315325 'onlypst' => array( 'Do a PST on the input, but don\'t parse it.',
316326 'Returns PSTed wikitext. Ignored if page or oldid is used.'
317327 ),
 328+ 'uselang' => 'Which language to parse the request in.'
318329 );
319330 }
320331
Index: trunk/phase3/RELEASE-NOTES
@@ -46,6 +46,7 @@
4747
4848 == API changes in 1.17 ==
4949 * (bug 22738) Allow filtering by action type on query=logevent
 50+* (bug 22764) uselang parameter for action=parse
5051
5152 === Languages updated in 1.17 ===
5253

Follow-up revisions

RevisionCommit summaryAuthorDate
r63430Minor comment for r63428reedy22:36, 8 March 2010
r63463Minor followup to r63425 and r63428...reedy11:52, 9 March 2010
r66150* (bug 23460) Parse action should have a section option...reedy18:27, 10 May 2010

Status & tagging log