Allow extensions to set a custom error message in the BlockIp hook
authorKunal Mehta <legoktm@gmail.com>
Sat, 18 Jan 2014 21:31:47 +0000 (13:31 -0800)
committerKunal Mehta <legoktm@gmail.com>
Sun, 19 Jan 2014 23:23:39 +0000 (15:23 -0800)
Change-Id: I2e3773e22c78370e6ca1de49e7b0976b68d8d76b

docs/hooks.txt
includes/specials/SpecialBlock.php

index b617430..51cf65c 100644 (file)
@@ -772,6 +772,7 @@ $block: Block object (which is set to be autoblocking)
 'BlockIp': Before an IP address or user is blocked.
 $block: the Block object about to be saved
 $user: the user _doing_ the block (not the one being blocked)
+&$reason: if the hook is aborted, the error message to be returned in an array
 
 'BlockIpComplete': After an IP address or user is blocked.
 $block: the Block object that was saved
index 1aa8006..61b59b9 100644 (file)
@@ -695,8 +695,9 @@ class SpecialBlock extends FormSpecialPage {
                $block->isAutoblocking( $data['AutoBlock'] );
                $block->mHideName = $data['HideUser'];
 
-               if ( !wfRunHooks( 'BlockIp', array( &$block, &$performer ) ) ) {
-                       return array( 'hookaborted' );
+               $reason = array( 'hookaborted' );
+               if ( !wfRunHooks( 'BlockIp', array( &$block, &$performer, &$reason ) ) ) {
+                       return $reason;
                }
 
                # Try to insert block. Is there a conflicting block?