aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiRollback.php
diff options
context:
space:
mode:
authorBrad Jorsch <bjorsch@wikimedia.org>2019-08-21 15:53:53 -0400
committerBrad Jorsch <bjorsch@wikimedia.org>2020-02-04 13:36:14 -0500
commitc2b15259081bdaa7cec892ba6b59c72b595254cc (patch)
tree118e61ce5eb79ba23f8603bbaa79d1ba14c8ef22 /includes/api/ApiRollback.php
parent054dd94e97d679385c0a9c17297d089b5e1ff192 (diff)
downloadmediawikicore-c2b15259081bdaa7cec892ba6b59c72b595254cc.tar.gz
mediawikicore-c2b15259081bdaa7cec892ba6b59c72b595254cc.zip
API: Use ParamValidator library
This brings significant modularization to the Action API's parameter validation, and allows the Action API and MW REST API to share validation code. Note there are several changes in this patch that may affect other code; see the entries in RELEASE-NOTES-1.35 for details. Bug: T142080 Bug: T232672 Bug: T21195 Bug: T34675 Bug: T154774 Change-Id: I1462edc1701278760fa695308007006868b249fc Depends-On: I10011be060fe6d27c7527312ad41218786b3f40d
Diffstat (limited to 'includes/api/ApiRollback.php')
-rw-r--r--includes/api/ApiRollback.php12
1 files changed, 5 insertions, 7 deletions
diff --git a/includes/api/ApiRollback.php b/includes/api/ApiRollback.php
index 7c313d5cb76d..59c87b3a4af9 100644
--- a/includes/api/ApiRollback.php
+++ b/includes/api/ApiRollback.php
@@ -20,6 +20,8 @@
* @file
*/
+use MediaWiki\ParamValidator\TypeDef\UserDef;
+
/**
* @ingroup API
*/
@@ -117,6 +119,8 @@ class ApiRollback extends ApiBase {
],
'user' => [
ApiBase::PARAM_TYPE => 'user',
+ UserDef::PARAM_ALLOWED_USER_TYPES => [ 'name', 'ip', 'id', 'interwiki' ],
+ UserDef::PARAM_RETURN_OBJECT => true,
ApiBase::PARAM_REQUIRED => true
],
'summary' => '',
@@ -151,13 +155,7 @@ class ApiRollback extends ApiBase {
return $this->mUser;
}
- // We need to be able to revert IPs, but getCanonicalName rejects them
- $this->mUser = User::isIP( $params['user'] )
- ? $params['user']
- : User::getCanonicalName( $params['user'] );
- if ( !$this->mUser ) {
- $this->dieWithError( [ 'apierror-invaliduser', wfEscapeWikiText( $params['user'] ) ] );
- }
+ $this->mUser = $params['user'];
return $this->mUser;
}