Prevent blocked users from performing revision deletion
authorAndrew H <crazy4sb@gmail.com>
Sun, 20 Dec 2015 23:49:10 +0000 (23:49 +0000)
committerAndrew H <crazy4sb@gmail.com>
Mon, 21 Dec 2015 02:16:03 +0000 (02:16 +0000)
Also fixed messege -> message in a comment.

Change-Id: Icee9a5816dae51a23c333ae49f47d14f5e08cb03

includes/api/ApiRevisionDelete.php
includes/api/ApiTag.php
includes/specials/SpecialRevisiondelete.php

index 7d89b69..b70b536 100644 (file)
@@ -41,6 +41,27 @@ class ApiRevisionDelete extends ApiBase {
                        $this->dieUsageMsg( 'badaccess-group0' );
                }
 
+               if ( $user->isBlocked() ) {
+                       $block = $user->getBlock();
+
+                       // Die using the appropriate message depending on block type
+                       if ( $block->getType() == TYPE_AUTO ) {
+                               $this->dieUsage(
+                                       'Your IP address has been blocked automatically, because it was used by a blocked user',
+                                       'autoblocked',
+                                       0,
+                                       array( 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $block ) )
+                               );
+                       } else {
+                               $this->dieUsage(
+                                       'You have been blocked from editing',
+                                       'blocked',
+                                       0,
+                                       array( 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $block ) )
+                               );
+                       }
+               }
+
                if ( !$params['ids'] ) {
                        $this->dieUsage( "At least one value is required for 'ids'", 'badparams' );
                }
index 2bba0e2..4157de0 100644 (file)
@@ -42,7 +42,7 @@ class ApiTag extends ApiBase {
                if ( $user->isBlocked() ) {
                        $block = $user->getBlock();
 
-                       // Die using the appropriate messege depending on block type
+                       // Die using the appropriate message depending on block type
                        if ( $block->getType() == TYPE_AUTO ) {
                                $this->dieUsage(
                                        'Your IP address has been blocked automatically, because it was used by a blocked user',
index 5ed0483..6dcbcb1 100644 (file)
@@ -118,6 +118,11 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                $output = $this->getOutput();
                $user = $this->getUser();
 
+               // Check blocks
+               if ( $user->isBlocked() ) {
+                       throw new UserBlockedError( $user->getBlock() );
+               }
+
                $this->setHeaders();
                $this->outputHeader();
                $request = $this->getRequest();