X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiBlock.php;h=480126760e137142984e09da1170673e96689d34;hb=902c7eef341ce5b7aae13113d2bb2369868e5b2a;hp=336943d054f7d66aa577c0e9864080ce6e4a9778;hpb=aac6b26c0bafc81287bb042304f1d346da94dc89;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiBlock.php b/includes/api/ApiBlock.php index 336943d054..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. @@ -52,7 +54,7 @@ class ApiBlock extends ApiBase { $this->dieWithError( $status, null, - [ 'blockinfo' => $this->getBlockInfo( $block ) ] + [ 'blockinfo' => $this->getBlockDetails( $block ) ] ); } } @@ -82,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' ); @@ -127,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 ) ); @@ -136,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 {