From: Aaron Schulz Date: Thu, 9 Jun 2016 21:53:47 +0000 (-0700) Subject: Add any prior block to BlockIpComplete hook X-Git-Tag: 1.31.0-rc.0~6393^2 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=b726f0ddeb888ec79137179338174affbd061625;p=lhc%2Fweb%2Fwiklou.git Add any prior block to BlockIpComplete hook Also fixed some $user IDEA warnings. Bug: T137287 Change-Id: I7c31e71e99dad0296244ced72b1e8949b8a8fa3d --- diff --git a/docs/hooks.txt b/docs/hooks.txt index c91354d2ff..9f5c4c48e6 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -885,6 +885,7 @@ $image: File 'BlockIpComplete': After an IP address or user is blocked. $block: the Block object that was saved $user: the user who did the block (not the one being blocked) +$priorBlock: the Block object for the prior block or null if there was none 'BookInformation': Before information output on Special:Booksources. $isbn: ISBN to show information for diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index fcadedebc1..ce7d24e57b 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -645,8 +645,10 @@ class SpecialBlock extends FormSpecialPage { return [ 'ipb-blockingself', 'ipb-confirmaction' ]; } } elseif ( $type == Block::TYPE_RANGE ) { + $user = null; $userId = 0; } elseif ( $type == Block::TYPE_IP ) { + $user = null; $target = $target->getName(); $userId = 0; } else { @@ -729,6 +731,7 @@ class SpecialBlock extends FormSpecialPage { return $reason; } + $priorBlock = null; # Try to insert block. Is there a conflicting block? $status = $block->insert(); if ( !$status ) { @@ -748,17 +751,16 @@ class SpecialBlock extends FormSpecialPage { # This returns direct blocks before autoblocks/rangeblocks, since we should # be sure the user is blocked by now it should work for our purposes $currentBlock = Block::newFromTarget( $target ); - if ( $block->equals( $currentBlock ) ) { return [ [ 'ipb_already_blocked', $block->getTarget() ] ]; } - # If the name was hidden and the blocking user cannot hide # names, then don't allow any block changes... if ( $currentBlock->mHideName && !$performer->isAllowed( 'hideuser' ) ) { return [ 'cant-see-hidden-user' ]; } + $priorBlock = clone $currentBlock; $currentBlock->isHardblock( $block->isHardblock() ); $currentBlock->prevents( 'createaccount', $block->prevents( 'createaccount' ) ); $currentBlock->mExpiry = $block->mExpiry; @@ -786,7 +788,7 @@ class SpecialBlock extends FormSpecialPage { $logaction = 'block'; } - Hooks::run( 'BlockIpComplete', [ $block, $performer ] ); + Hooks::run( 'BlockIpComplete', [ $block, $performer, $priorBlock ] ); # Set *_deleted fields if requested if ( $data['HideUser'] ) {