X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fapi%2FApiBlock.php;h=df30a2de7576ca0ffc3dd5f5d4846046ac9383a8;hp=8577ad28b9228b329e0d66ec90137f893dedd082;hb=827c6bfa416d9d0de8cc8e22f9f3fa36d8129d44;hpb=3287201b673c6e52c04e9f8771c0e71d1a617910 diff --git a/includes/api/ApiBlock.php b/includes/api/ApiBlock.php index 8577ad28b9..df30a2de75 100644 --- a/includes/api/ApiBlock.php +++ b/includes/api/ApiBlock.php @@ -67,12 +67,12 @@ class ApiBlock extends ApiBase { $params['user'] = $username; } } else { - $target = User::newFromName( $params['user'] ); + list( $target, $type ) = SpecialBlock::getTargetAndType( $params['user'] ); // T40633 - if the target is a user (not an IP address), but it // doesn't exist or is unusable, error. - if ( $target instanceof User && - ( $target->isAnon() /* doesn't exist */ || !User::isUsableName( $target->getName() ) ) + if ( $type === Block::TYPE_USER && + ( $target->isAnon() /* doesn't exist */ || !User::isUsableName( $params['user'] ) ) ) { $this->dieWithError( [ 'nosuchusershort', $params['user'] ], 'nosuchuser' ); } @@ -182,17 +182,17 @@ class ApiBlock extends ApiBase { } protected function getExamplesMessages() { - // @codingStandardsIgnoreStart Generic.Files.LineLength + // phpcs:disable Generic.Files.LineLength return [ 'action=block&user=192.0.2.5&expiry=3%20days&reason=First%20strike&token=123ABC' => 'apihelp-block-example-ip-simple', 'action=block&user=Vandal&expiry=never&reason=Vandalism&nocreate=&autoblock=&noemail=&token=123ABC' => 'apihelp-block-example-user-complex', ]; - // @codingStandardsIgnoreEnd + // phpcs:enable } public function getHelpUrls() { - return 'https://www.mediawiki.org/wiki/API:Block'; + return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Block'; } }