X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiBlock.php;h=480126760e137142984e09da1170673e96689d34;hb=8963110d01b0f376d900171fe7506fed5df80cf8;hp=b5d51aae8c7484edb9f00586700993be8197f97f;hpb=a8b38e84aca19857c74724014eb69402466a22ce;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiBlock.php b/includes/api/ApiBlock.php index b5d51aae8c..480126760e 100644 --- a/includes/api/ApiBlock.php +++ b/includes/api/ApiBlock.php @@ -20,6 +20,8 @@ * @file */ +use MediaWiki\Block\DatabaseBlock; + /** * API module that facilitates the blocking of users. Requires API write mode * to be enabled. @@ -28,6 +30,8 @@ */ class ApiBlock extends ApiBase { + use ApiBlockInfoTrait; + /** * Blocks the user specified in the parameters for the given expiry, with the * given reason, and with all other settings provided in the params. If the block @@ -50,7 +54,7 @@ class ApiBlock extends ApiBase { $this->dieWithError( $status, null, - [ 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $block ) ] + [ 'blockinfo' => $this->getBlockDetails( $block ) ] ); } } @@ -80,7 +84,7 @@ class ApiBlock extends ApiBase { // T40633 - if the target is a user (not an IP address), but it // doesn't exist or is unusable, error. - if ( $type === Block::TYPE_USER && + if ( $type === DatabaseBlock::TYPE_USER && ( $target->isAnon() /* doesn't exist */ || !User::isUsableName( $params['user'] ) ) ) { $this->dieWithError( [ 'nosuchusershort', $params['user'] ], 'nosuchuser' ); @@ -125,6 +129,11 @@ class ApiBlock extends ApiBase { 'NamespaceRestrictions' => $namespaceRestrictions, ]; + $status = SpecialBlock::validateTarget( $params['user'], $user ); + if ( !$status->isOK() ) { + $this->dieStatus( $status ); + } + $retval = SpecialBlock::processForm( $data, $this->getContext() ); if ( $retval !== true ) { $this->dieStatus( $this->errorArrayToStatus( $retval ) ); @@ -134,8 +143,8 @@ class ApiBlock extends ApiBase { $res['user'] = $params['user']; $res['userID'] = $target instanceof User ? $target->getId() : 0; - $block = Block::newFromTarget( $target, null, true ); - if ( $block instanceof Block ) { + $block = DatabaseBlock::newFromTarget( $target, null, true ); + if ( $block instanceof DatabaseBlock ) { $res['expiry'] = ApiResult::formatExpiry( $block->getExpiry(), 'infinite' ); $res['id'] = $block->getId(); } else {