From 173bd089b3161507a6b1f8c93886a172ba788574 Mon Sep 17 00:00:00 2001 From: Daimona Eaytoy Date: Mon, 9 Sep 2019 13:56:56 +0200 Subject: [PATCH] Remove script for blockautopromote entries It was executed on WMF wikis, and since they were the only affected wikis we can remove the script. Also remove a temporary back-compat check in the log formatter. Bug: T231131 Change-Id: I534acd9c86894eb1bdd96331e9fa85afc7502f88 --- includes/AbuseFilterRightsLogFormatter.php | 7 +- .../fixFirstBlockautopromoteEntries.php | 74 ------------------- 2 files changed, 1 insertion(+), 80 deletions(-) delete mode 100644 maintenance/fixFirstBlockautopromoteEntries.php diff --git a/includes/AbuseFilterRightsLogFormatter.php b/includes/AbuseFilterRightsLogFormatter.php index d69effe6d..95b4b5931 100644 --- a/includes/AbuseFilterRightsLogFormatter.php +++ b/includes/AbuseFilterRightsLogFormatter.php @@ -24,12 +24,7 @@ class AbuseFilterRightsLogFormatter extends LogFormatter { if ( $this->entry->getSubType() === 'blockautopromote' ) { $parameters = $this->entry->getParameters(); $duration = $parameters['7::duration']; - // @fixme Temporary for back-compat, all entries will have an int here - if ( is_int( $duration ) ) { - $ret[4] = $this->context->getLanguage()->formatDuration( $duration ); - } else { - $ret[4] = $duration; - } + $ret[4] = $this->context->getLanguage()->formatDuration( $duration ); } return $ret; } diff --git a/maintenance/fixFirstBlockautopromoteEntries.php b/maintenance/fixFirstBlockautopromoteEntries.php deleted file mode 100644 index 097ac869c..000000000 --- a/maintenance/fixFirstBlockautopromoteEntries.php +++ /dev/null @@ -1,74 +0,0 @@ -addDescription( 'Fix old blockautopromote log entries with hardcoded duration' ); - - $this->addOption( 'verbose', 'Print some more debug info' ); - $this->addOption( 'dry-run', 'Perform a dry run' ); - $this->requireExtension( 'Abuse Filter' ); - } - - /** - * @inheritDoc - */ - public function execute() { - $dbr = wfGetDB( DB_REPLICA, 'vslow' ); - $dbw = wfGetDB( DB_MASTER ); - $res = $dbr->select( - 'logging', - [ 'log_id', 'log_params' ], - [ - 'log_type' => 'rights', - 'log_action' => 'blockautopromote' - ], - __METHOD__ - ); - - $updated = []; - foreach ( $res as $row ) { - $params = unserialize( $row->log_params ); - $dur = $params['7::duration']; - if ( !is_int( $dur ) ) { - // This is the value that AbuseFilter::BLOCKAUTOPROMOTE_DURATION has for broken entries - $newVal = 5 * 86400; - $params['7::duration'] = $newVal; - - if ( !$this->hasOption( 'dry-run' ) ) { - $dbw->update( - 'logging', - [ 'log_params' => serialize( $params ) ], - [ 'log_id' => $row->log_id ], - __METHOD__ - ); - } - $updated[] = $row->log_id; - } - } - - $verb = $this->hasOption( 'dry-run' ) ? 'would update' : 'updated'; - $numUpd = count( $updated ); - $this->output( - __CLASS__ . ": $verb $numUpd rows out of " . $res->numRows() . " rows found.\n" - ); - if ( $updated && $this->hasOption( 'verbose' ) ) { - $this->output( 'The affected log IDs are: ' . implode( ', ', $updated ) . "\n" ); - } - return true; - } -} - -$maintClass = 'FixFirstBlockautopromoteEntries'; -require_once RUN_MAINTENANCE_IF_MAIN;