From ebdfe504d9f5e12ff59283332d817b0887ebec21 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Sat, 18 Jan 2014 13:31:47 -0800 Subject: [PATCH] Allow extensions to set a custom error message in the BlockIp hook Change-Id: I2e3773e22c78370e6ca1de49e7b0976b68d8d76b --- docs/hooks.txt | 1 + includes/specials/SpecialBlock.php | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index b61743000a..51cf65cebd 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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 diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index 1aa800690a..61b59b9ba4 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -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? -- 2.20.1