Ottomata has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/293756

Change subject: Pass previous IP/User block state to BlockIPComplete hook as 
$previousBlock
......................................................................

Pass previous IP/User block state to BlockIPComplete hook as $previousBlock

This will allow EventBus to log the complete block change -- what is was
before and what it being changed to now.

Bug: T137287
Change-Id: I6e1b0d63a9afcebe65b2590e181864037e08bdf9
---
M includes/specials/SpecialBlock.php
1 file changed, 9 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/56/293756/1

diff --git a/includes/specials/SpecialBlock.php 
b/includes/specials/SpecialBlock.php
index fcadede..5214d3d 100644
--- a/includes/specials/SpecialBlock.php
+++ b/includes/specials/SpecialBlock.php
@@ -729,6 +729,10 @@
                        return $reason;
                }
 
+               # This will be filled in with the 'current' block state if there
+               # is a conflicting block already in the database for this 
target.
+               $previousBlock = null;
+
                # Try to insert block. Is there a conflicting block?
                $status = $block->insert();
                if ( !$status ) {
@@ -748,6 +752,10 @@
                                # 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 );
+
+                               # Make a copy of the currentBlock so we can 
pass the previous
+                               # state to the BlockIPComplete hook later.
+                               $previousBlock = clone $currentBlock;
 
                                if ( $block->equals( $currentBlock ) ) {
                                        return [ [ 'ipb_already_blocked', 
$block->getTarget() ] ];
@@ -786,7 +794,7 @@
                        $logaction = 'block';
                }
 
-               Hooks::run( 'BlockIpComplete', [ $block, $performer ] );
+               Hooks::run( 'BlockIpComplete', [ $block, $performer, 
$previousBlock ] );
 
                # Set *_deleted fields if requested
                if ( $data['HideUser'] ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/293756
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6e1b0d63a9afcebe65b2590e181864037e08bdf9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ottomata <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to