Umherirrender has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/56373


Change subject: API: Set uselang as allowed param in ApiMain and document it
......................................................................

API: Set uselang as allowed param in ApiMain and document it

The uselang parameter is handled low level in RequestContext. But the
api will report a Unrecognized parameter warning, which is wrong,
because some api modules has effects on uselang.

Removed the safeguard in apiparse and apiwatch, because uselang
parameter and the context param is always the same.

Change-Id: Ieef40bc64b90d7793102ee48f36b00cd3d4a86fb
---
M includes/api/ApiMain.php
M includes/api/ApiParse.php
M includes/api/ApiWatch.php
3 files changed, 2 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/73/56373/1

diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php
index a6813e3..a14f334 100644
--- a/includes/api/ApiMain.php
+++ b/includes/api/ApiMain.php
@@ -1022,6 +1022,7 @@
                        'requestid' => null,
                        'servedby'  => false,
                        'origin' => null,
+                       'uselang' => null, # handled and validated low level in 
RequestContext
                );
        }
 
@@ -1052,6 +1053,7 @@
                                'If this parameter does not match the Origin: 
header, a 403 response will be returned.',
                                'If this parameter matches the Origin: header 
and the origin is whitelisted, an Access-Control-Allow-Origin header will be 
set.',
                        ),
+                       'uselang' => 'User language to use, when parsing html 
or messages for result',
                );
        }
 
diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php
index 09b7a88..0579900 100644
--- a/includes/api/ApiParse.php
+++ b/includes/api/ApiParse.php
@@ -68,13 +68,6 @@
                // TODO: Does this still need $wgTitle?
                global $wgParser, $wgTitle;
 
-               // Currently unnecessary, code to act as a safeguard against 
any change in current behavior of uselang
-               $oldLang = null;
-               if ( isset( $params['uselang'] ) && $params['uselang'] != 
$this->getContext()->getLanguage()->getCode() ) {
-                       $oldLang = $this->getContext()->getLanguage(); // 
Backup language
-                       $this->getContext()->setLanguage( Language::factory( 
$params['uselang'] ) );
-               }
-
                $redirValues = null;
 
                // Return result
@@ -339,10 +332,6 @@
                );
                $this->setIndexedTagNames( $result_array, $result_mapping );
                $result->addValue( null, $this->getModuleName(), $result_array 
);
-
-               if ( !is_null( $oldLang ) ) {
-                       $this->getContext()->setLanguage( $oldLang ); // Reset 
language to $oldLang
-               }
        }
 
        /**
@@ -575,7 +564,6 @@
                        ),
                        'pst' => false,
                        'onlypst' => false,
-                       'uselang' => null,
                        'section' => null,
                        'disablepp' => false,
                        'generatexml' => false,
@@ -626,7 +614,6 @@
                                'Do a pre-save transform (PST) on the input, 
but don\'t parse it',
                                'Returns the same wikitext, after a PST has 
been applied. Ignored if page, pageid or oldid is used'
                        ),
-                       'uselang' => 'Which language to parse the request in',
                        'section' => 'Only retrieve the content of this section 
number',
                        'disablepp' => 'Disable the PP Report from the parser 
output',
                        'generatexml' => 'Generate XML parse tree (requires 
prop=wikitext)',
diff --git a/includes/api/ApiWatch.php b/includes/api/ApiWatch.php
index 3e51299..0e82711 100644
--- a/includes/api/ApiWatch.php
+++ b/includes/api/ApiWatch.php
@@ -46,14 +46,6 @@
 
                $res = array( 'title' => $title->getPrefixedText() );
 
-               // Currently unnecessary, code to act as a safeguard against 
any change in current behavior of uselang
-               // Copy from ApiParse
-               $oldLang = null;
-               if ( isset( $params['uselang'] ) && $params['uselang'] != 
$this->getContext()->getLanguage()->getCode() ) {
-                       $oldLang = $this->getContext()->getLanguage(); // 
Backup language
-                       $this->getContext()->setLanguage( Language::factory( 
$params['uselang'] ) );
-               }
-
                if ( $params['unwatch'] ) {
                        $res['unwatched'] = '';
                        $res['message'] = $this->msg( 'removedwatchtext', 
$title->getPrefixedText() )->title( $title )->parseAsBlock();
@@ -62,10 +54,6 @@
                        $res['watched'] = '';
                        $res['message'] = $this->msg( 'addedwatchtext', 
$title->getPrefixedText() )->title( $title )->parseAsBlock();
                        $success = WatchAction::doWatch( $title, $user );
-               }
-
-               if ( !is_null( $oldLang ) ) {
-                       $this->getContext()->setLanguage( $oldLang ); // Reset 
language to $oldLang
                }
 
                if ( !$success ) {
@@ -97,7 +85,6 @@
                                ApiBase::PARAM_REQUIRED => true
                        ),
                        'unwatch' => false,
-                       'uselang' => null,
                        'token' => array(
                                ApiBase::PARAM_TYPE => 'string',
                                ApiBase::PARAM_REQUIRED => true
@@ -109,7 +96,6 @@
                return array(
                        'title' => 'The page to (un)watch',
                        'unwatch' => 'If set the page will be unwatched rather 
than watched',
-                       'uselang' => 'Language to show the message in',
                        'token' => 'A token previously acquired via prop=info',
                );
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/56373
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieef40bc64b90d7793102ee48f36b00cd3d4a86fb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to