summaryrefslogtreecommitdiff
path: root/includes/api/ApiBlock.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-08-12 09:28:15 +0200
committerPierre Schmitz <pierre@archlinux.de>2013-08-12 09:28:15 +0200
commit08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 (patch)
tree577a29fb579188d16003a209ce2a2e9c5b0aa2bd /includes/api/ApiBlock.php
parentcacc939b34e315b85e2d72997811eb6677996cc1 (diff)
Update to MediaWiki 1.21.1
Diffstat (limited to 'includes/api/ApiBlock.php')
-rw-r--r--includes/api/ApiBlock.php29
1 files changed, 15 insertions, 14 deletions
diff --git a/includes/api/ApiBlock.php b/includes/api/ApiBlock.php
index c879b35d..90432b95 100644
--- a/includes/api/ApiBlock.php
+++ b/includes/api/ApiBlock.php
@@ -25,17 +25,13 @@
*/
/**
-* API module that facilitates the blocking of users. Requires API write mode
-* to be enabled.
-*
+ * API module that facilitates the blocking of users. Requires API write mode
+ * to be enabled.
+ *
* @ingroup API
*/
class ApiBlock extends ApiBase {
- public function __construct( $main, $action ) {
- parent::__construct( $main, $action );
- }
-
/**
* 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
@@ -55,6 +51,7 @@ class ApiBlock extends ApiBase {
if ( !$user->isAllowed( 'block' ) ) {
$this->dieUsageMsg( 'cantblock' );
}
+
# bug 15810: blocked admins should have limited access here
if ( $user->isBlocked() ) {
$status = SpecialBlock::checkUnblockSelf( $params['user'], $user );
@@ -62,6 +59,13 @@ class ApiBlock extends ApiBase {
$this->dieUsageMsg( array( $status ) );
}
}
+
+ $target = User::newFromName( $params['user'] );
+ // Bug 38633 - 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() ) ) ) {
+ $this->dieUsageMsg( array( 'nosuchuser', $params['user'] ) );
+ }
+
if ( $params['hidename'] && !$user->isAllowed( 'hideuser' ) ) {
$this->dieUsageMsg( 'canthide' );
}
@@ -70,6 +74,7 @@ class ApiBlock extends ApiBase {
}
$data = array(
+ 'PreviousTarget' => $params['user'],
'Target' => $params['user'],
'Reason' => array(
$params['reason'],
@@ -83,7 +88,7 @@ class ApiBlock extends ApiBase {
'DisableEmail' => $params['noemail'],
'HideUser' => $params['hidename'],
'DisableUTEdit' => !$params['allowusertalk'],
- 'AlreadyBlocked' => $params['reblock'],
+ 'Reblock' => $params['reblock'],
'Watch' => $params['watchuser'],
'Confirm' => true,
);
@@ -99,7 +104,7 @@ class ApiBlock extends ApiBase {
$res['userID'] = $target instanceof User ? $target->getId() : 0;
$block = Block::newFromTarget( $target );
- if( $block instanceof Block ){
+ if( $block instanceof Block ) {
$res['expiry'] = $block->mExpiry == $this->getDB()->getInfinity()
? 'infinite'
: wfTimestamp( TS_ISO_8601, $block->mExpiry );
@@ -178,7 +183,7 @@ class ApiBlock extends ApiBase {
'anononly' => 'Block anonymous users only (i.e. disable anonymous edits for this IP)',
'nocreate' => 'Prevent account creation',
'autoblock' => 'Automatically block the last used IP address, and any subsequent IP addresses they try to login from',
- 'noemail' => 'Prevent user from sending e-mail through the wiki. (Requires the "blockemail" right.)',
+ 'noemail' => 'Prevent user from sending email through the wiki. (Requires the "blockemail" right.)',
'hidename' => 'Hide the username from the block log. (Requires the "hideuser" right.)',
'allowusertalk' => 'Allow the user to edit their own talk page (depends on $wgBlockAllowsUTEdit)',
'reblock' => 'If the user is already blocked, overwrite the existing block',
@@ -256,8 +261,4 @@ class ApiBlock extends ApiBase {
public function getHelpUrls() {
return 'https://www.mediawiki.org/wiki/API:Block';
}
-
- public function getVersion() {
- return __CLASS__ . ': $Id$';
- }
}