HHVM removal: Deprecate and simplify wfIsHHVM()
[lhc/web/wiklou.git] / includes / api / ApiUnblock.php
index 1c72b67..15c2564 100644 (file)
@@ -20,6 +20,8 @@
  * @file
  */
 
+use MediaWiki\Block\DatabaseBlock;
+
 /**
  * API module that facilitates the unblocking of users. Requires API write mode
  * to be enabled.
@@ -39,7 +41,7 @@ class ApiUnblock extends ApiBase {
 
                $this->requireOnlyOneParameter( $params, 'id', 'user', 'userid' );
 
-               if ( !$user->isAllowed( 'block' ) ) {
+               if ( !$this->getPermissionManager()->userHasRight( $user, 'block' ) ) {
                        $this->dieWithError( 'apierror-permissiondenied-unblock', 'permissiondenied' );
                }
                # T17810: blocked admins should have limited access here
@@ -78,17 +80,19 @@ class ApiUnblock extends ApiBase {
                        'Reason' => $params['reason'],
                        'Tags' => $params['tags']
                ];
-               $block = Block::newFromTarget( $data['Target'] );
+               $block = DatabaseBlock::newFromTarget( $data['Target'] );
                $retval = SpecialUnblock::processUnblock( $data, $this->getContext() );
                if ( $retval !== true ) {
                        $this->dieStatus( $this->errorArrayToStatus( $retval ) );
                }
 
-               $res['id'] = $block->getId();
-               $target = $block->getType() == Block::TYPE_AUTO ? '' : $block->getTarget();
-               $res['user'] = $target instanceof User ? $target->getName() : $target;
-               $res['userid'] = $target instanceof User ? $target->getId() : 0;
-               $res['reason'] = $params['reason'];
+               $target = $block->getType() == DatabaseBlock::TYPE_AUTO ? '' : $block->getTarget();
+               $res = [
+                       'id' => $block->getId(),
+                       'user' => $target instanceof User ? $target->getName() : $target,
+                       'userid' => $target instanceof User ? $target->getId() : 0,
+                       'reason' => $params['reason']
+               ];
                $this->getResult()->addValue( null, $this->getModuleName(), $res );
        }