API: Flag "user" parameters in various modules as type 'user'
authorBrad Jorsch <bjorsch@wikimedia.org>
Mon, 4 Jan 2016 18:55:26 +0000 (10:55 -0800)
committerReedy <reedy@wikimedia.org>
Sat, 9 Jan 2016 22:16:06 +0000 (22:16 +0000)
The API 'user' type accepts both user names and IP addresses, and
applies normalization but not canonicalization. We should be using this
on basically every user parameter to ensure that e.g. IPv6 usernames get
uppercased.

Bug: T122803
Change-Id: Ic67fb54061ac311e54f325b2a1a4658f43b8fef4

includes/api/ApiBase.php
includes/api/ApiBlock.php
includes/api/ApiQueryBlocks.php
includes/api/ApiQueryLogEvents.php
includes/api/ApiQueryUserContributions.php
includes/api/ApiQueryUsers.php
includes/api/ApiRollback.php
includes/api/ApiUserrights.php

index 56a8a7a..5f67a22 100644 (file)
@@ -79,7 +79,7 @@ abstract class ApiBase extends ContextSource {
         * - timestamp: A timestamp in any format recognized by MWTimestamp, or the
         *   string 'now' representing the current timestamp. Will be returned in
         *   TS_MW format.
-        * - user: A MediaWiki username. Will be returned normalized but not canonicalized.
+        * - user: A MediaWiki username or IP. Will be returned normalized but not canonicalized.
         * - upload: An uploaded file. Will be returned as a WebRequestUpload object.
         *   Cannot be used with PARAM_ISMULTI.
         */
index 636baa7..e3d73a2 100644 (file)
@@ -141,7 +141,7 @@ class ApiBlock extends ApiBase {
        public function getAllowedParams() {
                return array(
                        'user' => array(
-                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_TYPE => 'user',
                                ApiBase::PARAM_REQUIRED => true
                        ),
                        'expiry' => 'never',
index d004020..229e3d1 100644 (file)
@@ -273,6 +273,7 @@ class ApiQueryBlocks extends ApiQueryBase {
                                ApiBase::PARAM_ISMULTI => true
                        ),
                        'users' => array(
+                               ApiBase::PARAM_TYPE => 'user',
                                ApiBase::PARAM_ISMULTI => true
                        ),
                        'ip' => array(
index 38be99a..a76012a 100644 (file)
@@ -165,7 +165,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                        if ( $userid ) {
                                $this->addWhereFld( 'log_user', $userid );
                        } else {
-                               $this->addWhereFld( 'log_user_text', IP::sanitizeIP( $user ) );
+                               $this->addWhereFld( 'log_user_text', $user );
                        }
                }
 
@@ -430,7 +430,9 @@ class ApiQueryLogEvents extends ApiQueryBase {
                                ),
                                ApiBase::PARAM_HELP_MSG => 'api-help-param-direction',
                        ),
-                       'user' => null,
+                       'user' => array(
+                               ApiBase::PARAM_TYPE => 'user',
+                       ),
                        'title' => null,
                        'namespace' => array(
                                ApiBase::PARAM_TYPE => 'namespace'
index 1ef0f35..27a28e1 100644 (file)
@@ -461,6 +461,7 @@ class ApiQueryContributions extends ApiQueryBase {
                                ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
                        ),
                        'user' => array(
+                               ApiBase::PARAM_TYPE => 'user',
                                ApiBase::PARAM_ISMULTI => true
                        ),
                        'userprefix' => null,
index db5fb65..ea9d48d 100644 (file)
@@ -317,6 +317,7 @@ class ApiQueryUsers extends ApiQueryBase {
                        ),
                        'attachedwiki' => null,
                        'users' => array(
+                               ApiBase::PARAM_TYPE => 'user',
                                ApiBase::PARAM_ISMULTI => true
                        ),
                        'token' => array(
index 7037fb6..0fa2e31 100644 (file)
@@ -126,7 +126,7 @@ class ApiRollback extends ApiBase {
                                ApiBase::PARAM_ISMULTI => true,
                        ),
                        'user' => array(
-                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_TYPE => 'user',
                                ApiBase::PARAM_REQUIRED => true
                        ),
                        'summary' => '',
index e32b612..815ef0b 100644 (file)
@@ -112,7 +112,7 @@ class ApiUserrights extends ApiBase {
        public function getAllowedParams() {
                return array(
                        'user' => array(
-                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_TYPE => 'user',
                        ),
                        'userid' => array(
                                ApiBase::PARAM_TYPE => 'integer',