Add any prior block to BlockIpComplete hook
Also fixed some $user IDEA warnings. Bug: T137287 Change-Id: I7c31e71e99dad0296244ced72b1e8949b8a8fa3d
This commit is contained in:
parent
605e49362e
commit
b726f0ddeb
2 changed files with 6 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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'] ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue