X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_del%27%2C%20idvote=vote.voteid%29%20%7D%7D?a=blobdiff_plain;f=maintenance%2FupdateCollation.php;h=12b33b47bb8524becf03b6b18de6ede6b898cc2d;hb=102bfd66c84dbb9b690c78ad0c3975b7dc8f1a0a;hp=63176cb6ef4fb0f87f20a6c39a32ac8b45a75bf9;hpb=3f59cb9f3a53ad28f8a95fe299c5de6abd24b453;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/updateCollation.php b/maintenance/updateCollation.php index 63176cb6ef..12b33b47bb 100644 --- a/maintenance/updateCollation.php +++ b/maintenance/updateCollation.php @@ -187,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', [ @@ -213,6 +211,7 @@ TEXT [ 'cl_from' => $row->cl_from, 'cl_to' => $row->cl_to ], __METHOD__ ); + $count++; } if ( $row ) { $batchConds = [ $this->getBatchCondition( $row, $dbw ) ]; @@ -222,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" ); @@ -306,11 +304,7 @@ TEXT if ( $raw !== '' ) { $raw .= ', '; } - if ( !isset( $this->sizeHistogram[$i] ) ) { - $val = 0; - } else { - $val = $this->sizeHistogram[$i]; - } + $val = $this->sizeHistogram[$i] ?? 0; for ( $coarseIndex = 0; $coarseIndex < $numBins - 1; $coarseIndex++ ) { if ( $coarseBoundaries[$coarseIndex] > $i ) { $coarseHistogram[$coarseIndex] += $val; @@ -329,11 +323,7 @@ TEXT $scale = 60 / $maxBinVal; $prevBoundary = 0; for ( $coarseIndex = 0; $coarseIndex < $numBins; $coarseIndex++ ) { - if ( !isset( $coarseHistogram[$coarseIndex] ) ) { - $val = 0; - } else { - $val = $coarseHistogram[$coarseIndex]; - } + $val = $coarseHistogram[$coarseIndex] ?? 0; $boundary = $coarseBoundaries[$coarseIndex]; $this->output( sprintf( "%-10s %-10d |%s\n", $prevBoundary . '-' . ( $boundary - 1 ) . ': ',