Include block ID in unblock log
authorGergő Tisza <tgr.huwiki@gmail.com>
Tue, 18 Dec 2018 07:50:05 +0000 (23:50 -0800)
committerGergő Tisza <tgr.huwiki@gmail.com>
Wed, 19 Dec 2018 08:08:23 +0000 (00:08 -0800)
Also change block log to only include the ID of the block.
Including autoblock IDs just makes analysis harder, and it is not
useful when searching for autoblocks since those created when a
blocked user tries to edit are not logged this way.

Bug: T210476
Change-Id: Iff1697be416abbb807227d0629cf41346bd379c2

includes/specials/SpecialBlock.php
includes/specials/SpecialUnblock.php

index 67d1873..c9ce2b0 100644 (file)
@@ -882,6 +882,7 @@ class SpecialBlock extends FormSpecialPage {
                                }
 
                                $status = $currentBlock->update();
+                               // TODO handle failure
 
                                $logaction = 'reblock';
 
@@ -894,6 +895,8 @@ class SpecialBlock extends FormSpecialPage {
                                if ( (bool)$currentBlock->mHideName ) {
                                        $data['HideUser'] = true;
                                }
+
+                               $block = $currentBlock;
                        }
                } else {
                        $logaction = 'block';
@@ -938,9 +941,8 @@ class SpecialBlock extends FormSpecialPage {
                $logEntry->setComment( $data['Reason'][0] );
                $logEntry->setPerformer( $performer );
                $logEntry->setParameters( $logParams );
-               # Relate log ID to block IDs (T27763)
-               $blockIds = array_merge( [ $status['id'] ], $status['autoIds'] );
-               $logEntry->setRelations( [ 'ipb_id' => $blockIds ] );
+               # Relate log ID to block ID (T27763)
+               $logEntry->setRelations( [ 'ipb_id' => $block->getId() ] );
                $logId = $logEntry->insert();
 
                if ( !empty( $data['Tags'] ) ) {
index b2d5a16..632415c 100644 (file)
@@ -248,6 +248,7 @@ class SpecialUnblock extends SpecialPage {
                if ( isset( $data['Tags'] ) ) {
                        $logEntry->setTags( $data['Tags'] );
                }
+               $logEntry->setRelations( [ 'ipb_id' => $block->getId() ] );
                $logId = $logEntry->insert();
                $logEntry->publish( $logId );