Follow-up I68179974: Remove from 1.33 RL, backported to 1.32
[lhc/web/wiklou.git] / includes / actions / Action.php
index fb761a7..f288a5c 100644 (file)
@@ -30,7 +30,7 @@ use MediaWiki\MediaWikiServices;
  * are distinct from Special Pages because an action must apply to exactly one page.
  *
  * To add an action in an extension, create a subclass of Action, and add the key to
- * $wgActions.  There is also the deprecated UnknownAction hook
+ * $wgActions.
  *
  * Actions generally fall into two groups: the show-a-form-then-do-something-with-the-input
  * format (protect, delete, move, etc), and the just-do-something format (watch, rollback,
@@ -314,9 +314,14 @@ abstract class Action implements MessageLocalizer {
                        }
                }
 
-               if ( $this->requiresUnblock() && $user->isBlocked() ) {
+               // If the action requires an unblock, explicitly check the user's block.
+               if ( $this->requiresUnblock() && $user->isBlockedFrom( $this->getTitle() ) ) {
                        $block = $user->getBlock();
-                       throw new UserBlockedError( $block );
+                       if ( $block ) {
+                               throw new UserBlockedError( $block );
+                       }
+
+                       throw new PermissionsError( $this->getName(), [ 'badaccess-group0' ] );
                }
 
                // This should be checked at the end so that the user won't think the