X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FupdateCollation.php;h=06704549470bd19c55a27b47e83f4f688afe7196;hb=32d29b4a681048009d9ce2f986a6ad737b07cc94;hp=e754e3c3abb3d6080717909fbf717e15e511ecc8;hpb=00ac2882bbfa81c226250efc06586a5ab50bf3f8;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/updateCollation.php b/maintenance/updateCollation.php index e754e3c3ab..0670454947 100644 --- a/maintenance/updateCollation.php +++ b/maintenance/updateCollation.php @@ -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. @@ -185,20 +187,18 @@ TEXT } # cl_type will be wrong for lots of pages if cl_collation is 0, # so let's update it while we're here. - if ( $title->getNamespace() == NS_CATEGORY ) { - $type = 'subcat'; - } elseif ( $title->getNamespace() == NS_FILE ) { - $type = 'file'; - } else { - $type = 'page'; - } + $type = MWNamespace::getCategoryLinkType( $title->getNamespace() ); $newSortKey = $collation->getSortKey( $title->getCategorySortkey( $prefix ) ); if ( $verboseStats ) { $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 +211,7 @@ TEXT [ 'cl_from' => $row->cl_from, 'cl_to' => $row->cl_to ], __METHOD__ ); + $count++; } if ( $row ) { $batchConds = [ $this->getBatchCondition( $row, $dbw ) ]; @@ -220,17 +221,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 +242,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 DatabaseBase $dbw + * @param IDatabase $dbw * @return string */ function getBatchCondition( $row, $dbw ) { @@ -342,5 +342,5 @@ TEXT } } -$maintClass = "UpdateCollation"; +$maintClass = UpdateCollation::class; require_once RUN_MAINTENANCE_IF_MAIN;