$user = $this->getUser();
$params = $this->extractRequestParams();
- $this->requireOnlyOneParameter( $params, 'id', 'user' );
+ $this->requireOnlyOneParameter( $params, 'id', 'user', 'userid' );
if ( !$user->isAllowed( 'block' ) ) {
$this->dieWithError( 'apierror-permissiondenied-unblock', 'permissiondenied' );
}
- # bug 15810: blocked admins should have limited access here
+ # T17810: blocked admins should have limited access here
if ( $user->isBlocked() ) {
$status = SpecialBlock::checkUnblockSelf( $params['user'], $user );
if ( $status !== true ) {
}
}
+ if ( $params['userid'] !== null ) {
+ $username = User::whoIs( $params['userid'] );
+
+ if ( $username === false ) {
+ $this->dieWithError( [ 'apierror-nosuchuserid', $params['userid'] ], 'nosuchuserid' );
+ } else {
+ $params['user'] = $username;
+ }
+ }
+
$data = [
'Target' => is_null( $params['id'] ) ? $params['user'] : "#{$params['id']}",
'Reason' => $params['reason'],
ApiBase::PARAM_TYPE => 'integer',
],
'user' => null,
+ 'userid' => [
+ ApiBase::PARAM_TYPE => 'integer'
+ ],
'reason' => '',
'tags' => [
ApiBase::PARAM_TYPE => 'tags',