Declare LogFormatter::$parsedParameters property
[lhc/web/wiklou.git] / maintenance / updateCollation.php
index e70a176..d88d5e9 100644 (file)
@@ -26,6 +26,8 @@
 
 require_once __DIR__ . '/Maintenance.php';
 
+use Wikimedia\Rdbms\IDatabase;
+
 /**
  * Maintenance script that will find all rows in the categorylinks table
  * whose collation is out-of-date.
@@ -198,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',
                                                [
@@ -211,6 +217,7 @@ TEXT
                                                [ 'cl_from' => $row->cl_from, 'cl_to' => $row->cl_to ],
                                                __METHOD__
                                        );
+                                       $count++;
                                }
                                if ( $row ) {
                                        $batchConds = [ $this->getBatchCondition( $row, $dbw ) ];
@@ -220,17 +227,16 @@ TEXT
                                $this->commitTransaction( $dbw, __METHOD__ );
                        }
 
-                       $count += $res->numRows();
-                       $this->output( "$count done.\n" );
-
-                       if ( !$dryRun && ++$batchCount % self::SYNC_INTERVAL == 0 ) {
-                               $this->output( "Waiting for replica DBs ... " );
-                               wfWaitForSlaves();
-                               $this->output( "done\n" );
+                       if ( $dryRun ) {
+                               $this->output( "$count rows would be updated so far.\n" );
+                       } else {
+                               $this->output( "$count done.\n" );
                        }
                } 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" );
@@ -242,7 +248,7 @@ TEXT
         * Return an SQL expression selecting rows which sort above the given row,
         * assuming an ordering of cl_collation, cl_to, cl_type, cl_from
         * @param stdClass $row
-        * @param Database $dbw
+        * @param IDatabase $dbw
         * @return string
         */
        function getBatchCondition( $row, $dbw ) {
@@ -342,5 +348,5 @@ TEXT
        }
 }
 
-$maintClass = "UpdateCollation";
+$maintClass = UpdateCollation::class;
 require_once RUN_MAINTENANCE_IF_MAIN;