Merge "Drop index oi_name_archive_name on table oldimage"
[lhc/web/wiklou.git] / includes / api / ApiUnblock.php
index 523a888..bfb0324 100644 (file)
@@ -39,12 +39,12 @@ class ApiUnblock extends ApiBase {
                $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 ) {
@@ -64,6 +64,16 @@ class ApiUnblock extends ApiBase {
                        }
                }
 
+               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'],
@@ -97,6 +107,9 @@ class ApiUnblock extends ApiBase {
                                ApiBase::PARAM_TYPE => 'integer',
                        ],
                        'user' => null,
+                       'userid' => [
+                               ApiBase::PARAM_TYPE => 'integer'
+                       ],
                        'reason' => '',
                        'tags' => [
                                ApiBase::PARAM_TYPE => 'tags',