jenkins-bot has submitted this change and it was merged.

Change subject: API: Flag "user" parameters in various modules as type 'user'
......................................................................


API: Flag "user" parameters in various modules as type 'user'

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
---
M includes/api/ApiBase.php
M includes/api/ApiBlock.php
M includes/api/ApiQueryBlocks.php
M includes/api/ApiQueryLogEvents.php
M includes/api/ApiQueryUserContributions.php
M includes/api/ApiQueryUsers.php
M includes/api/ApiRollback.php
M includes/api/ApiUserrights.php
8 files changed, 11 insertions(+), 6 deletions(-)

Approvals:
  Reedy: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php
index 56a8a7a..5f67a22 100644
--- a/includes/api/ApiBase.php
+++ b/includes/api/ApiBase.php
@@ -79,7 +79,7 @@
         * - 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.
         */
diff --git a/includes/api/ApiBlock.php b/includes/api/ApiBlock.php
index 636baa7..e3d73a2 100644
--- a/includes/api/ApiBlock.php
+++ b/includes/api/ApiBlock.php
@@ -141,7 +141,7 @@
        public function getAllowedParams() {
                return array(
                        'user' => array(
-                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_TYPE => 'user',
                                ApiBase::PARAM_REQUIRED => true
                        ),
                        'expiry' => 'never',
diff --git a/includes/api/ApiQueryBlocks.php b/includes/api/ApiQueryBlocks.php
index d004020..229e3d1 100644
--- a/includes/api/ApiQueryBlocks.php
+++ b/includes/api/ApiQueryBlocks.php
@@ -273,6 +273,7 @@
                                ApiBase::PARAM_ISMULTI => true
                        ),
                        'users' => array(
+                               ApiBase::PARAM_TYPE => 'user',
                                ApiBase::PARAM_ISMULTI => true
                        ),
                        'ip' => array(
diff --git a/includes/api/ApiQueryLogEvents.php 
b/includes/api/ApiQueryLogEvents.php
index 38be99a..a76012a 100644
--- a/includes/api/ApiQueryLogEvents.php
+++ b/includes/api/ApiQueryLogEvents.php
@@ -165,7 +165,7 @@
                        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 @@
                                ),
                                ApiBase::PARAM_HELP_MSG => 
'api-help-param-direction',
                        ),
-                       'user' => null,
+                       'user' => array(
+                               ApiBase::PARAM_TYPE => 'user',
+                       ),
                        'title' => null,
                        'namespace' => array(
                                ApiBase::PARAM_TYPE => 'namespace'
diff --git a/includes/api/ApiQueryUserContributions.php 
b/includes/api/ApiQueryUserContributions.php
index 1ef0f35..27a28e1 100644
--- a/includes/api/ApiQueryUserContributions.php
+++ b/includes/api/ApiQueryUserContributions.php
@@ -461,6 +461,7 @@
                                ApiBase::PARAM_HELP_MSG => 
'api-help-param-continue',
                        ),
                        'user' => array(
+                               ApiBase::PARAM_TYPE => 'user',
                                ApiBase::PARAM_ISMULTI => true
                        ),
                        'userprefix' => null,
diff --git a/includes/api/ApiQueryUsers.php b/includes/api/ApiQueryUsers.php
index db5fb65..ea9d48d 100644
--- a/includes/api/ApiQueryUsers.php
+++ b/includes/api/ApiQueryUsers.php
@@ -317,6 +317,7 @@
                        ),
                        'attachedwiki' => null,
                        'users' => array(
+                               ApiBase::PARAM_TYPE => 'user',
                                ApiBase::PARAM_ISMULTI => true
                        ),
                        'token' => array(
diff --git a/includes/api/ApiRollback.php b/includes/api/ApiRollback.php
index 7037fb6..0fa2e31 100644
--- a/includes/api/ApiRollback.php
+++ b/includes/api/ApiRollback.php
@@ -126,7 +126,7 @@
                                ApiBase::PARAM_ISMULTI => true,
                        ),
                        'user' => array(
-                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_TYPE => 'user',
                                ApiBase::PARAM_REQUIRED => true
                        ),
                        'summary' => '',
diff --git a/includes/api/ApiUserrights.php b/includes/api/ApiUserrights.php
index e32b612..815ef0b 100644
--- a/includes/api/ApiUserrights.php
+++ b/includes/api/ApiUserrights.php
@@ -112,7 +112,7 @@
        public function getAllowedParams() {
                return array(
                        'user' => array(
-                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_TYPE => 'user',
                        ),
                        'userid' => array(
                                ApiBase::PARAM_TYPE => 'integer',

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic67fb54061ac311e54f325b2a1a4658f43b8fef4
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to