From 75747c0fcc84136ae86568d3edaf85e0b66ecc29 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Thu, 15 Feb 2018 18:52:26 +0100 Subject: [PATCH] updateCollation.php: Improve --dry-run mode Now prints the number of rows that would be modified after each batch. This is meant to be useful for sysadmins who are upgrading the ICU library on their servers and wondering whether they need to run `updateCollation.php --force` to avoid ordering problems. Change-Id: Ie0c37d279d4e5bc1c69408d714246625c81c70fa --- maintenance/updateCollation.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/maintenance/updateCollation.php b/maintenance/updateCollation.php index 63176cb6ef..54ae1301f1 100644 --- a/maintenance/updateCollation.php +++ b/maintenance/updateCollation.php @@ -200,7 +200,11 @@ TEXT $this->updateSortKeySizeHistogram( $newSortKey ); } - if ( !$dryRun ) { + if ( $dryRun ) { + // Add 1 to the count if the sortkey was changed. (Note that this doesn't count changes in + // other fields, if any, those usually only happen when upgrading old MediaWikis.) + $count += ( $row->cl_sortkey !== $newSortKey ); + } else { $dbw->update( 'categorylinks', [ @@ -213,6 +217,7 @@ TEXT [ 'cl_from' => $row->cl_from, 'cl_to' => $row->cl_to ], __METHOD__ ); + $count++; } if ( $row ) { $batchConds = [ $this->getBatchCondition( $row, $dbw ) ]; @@ -222,8 +227,11 @@ TEXT $this->commitTransaction( $dbw, __METHOD__ ); } - $count += $res->numRows(); - $this->output( "$count done.\n" ); + if ( $dryRun ) { + $this->output( "$count rows would be updated so far.\n" ); + } else { + $this->output( "$count done.\n" ); + } if ( !$dryRun && ++$batchCount % self::SYNC_INTERVAL == 0 ) { $this->output( "Waiting for replica DBs ... " ); @@ -232,7 +240,9 @@ TEXT } } while ( $res->numRows() == self::BATCH_SIZE ); - $this->output( "$count rows processed\n" ); + if ( !$dryRun ) { + $this->output( "$count rows processed\n" ); + } if ( $verboseStats ) { $this->output( "\n" ); -- 2.20.1