X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fapi%2FApiBlock.php;h=8f4028310a790697988b9226bd026f600c8e0c7f;hp=4d37af31627891d293801787ba21dad2515a9d3f;hb=19e9e672f31c792622fc8c27ad511f27263979a8;hpb=3cb14f56bdf3271769a5866f9dcaad56bf873aea diff --git a/includes/api/ApiBlock.php b/includes/api/ApiBlock.php index 4d37af3162..8f4028310a 100644 --- a/includes/api/ApiBlock.php +++ b/includes/api/ApiBlock.php @@ -1,9 +1,5 @@ .@gmail.com" * * This program is free software; you can redistribute it and/or modify @@ -67,12 +63,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' ); } @@ -128,8 +124,8 @@ class ApiBlock extends ApiBase { $res['id'] = $block->getId(); } else { # should be unreachable - $res['expiry'] = ''; - $res['id'] = ''; + $res['expiry'] = ''; // @codeCoverageIgnore + $res['id'] = ''; // @codeCoverageIgnore } $res['reason'] = $params['reason']; @@ -182,14 +178,14 @@ 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() {