X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2FupdateCollation.php;h=342ffbad65426a3eca436a62669e0ee612e85d5e;hb=85500c240dd18f460cdabf37b669d610cf520400;hp=b847c23b05cacced1201be3871471d32253ecd2f;hpb=5cfec935722d8f4015dc24cda1de8bfc7f330537;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/updateCollation.php b/maintenance/updateCollation.php index b847c23b05..342ffbad65 100644 --- a/maintenance/updateCollation.php +++ b/maintenance/updateCollation.php @@ -47,7 +47,7 @@ class UpdateCollation extends Maintenance { $this->mDescription = <<getFirstLetter( 'MediaWiki' ); + $options = array( 'LIMIT' => self::BATCH_SIZE, 'ORDER BY' => 'cl_to, cl_type, cl_from', @@ -116,6 +120,7 @@ TEXT; } if ( $count == 0 ) { $this->output( "Collations up-to-date.\n" ); + return; } $this->output( "Fixing collation for $count rows.\n" ); @@ -146,7 +151,8 @@ TEXT; # This is an old-style row, so the sortkey needs to be # converted. if ( $row->cl_sortkey == $title->getText() - || $row->cl_sortkey == $title->getPrefixedText() ) { + || $row->cl_sortkey == $title->getPrefixedText() + ) { $prefix = ''; } else { # Custom sortkey, use it as a prefix @@ -184,15 +190,14 @@ TEXT; __METHOD__ ); } + if ( $row ) { + $batchConds = array( $this->getBatchCondition( $row, $dbw ) ); + } } if ( !$dryRun ) { $dbw->commit( __METHOD__ ); } - if ( $row ) { - $batchConds = array( $this->getBatchCondition( $row ) ); - } - $count += $res->numRows(); $this->output( "$count done.\n" ); @@ -214,9 +219,11 @@ TEXT; /** * Return an SQL expression selecting rows which sort above the given row, * assuming an ordering of cl_to, cl_type, cl_from + * @param stdClass $row + * @param DatabaseBase $dbw + * @return string */ - function getBatchCondition( $row ) { - $dbw = $this->getDB( DB_MASTER ); + function getBatchCondition( $row, $dbw ) { $fields = array( 'cl_to', 'cl_type', 'cl_from' ); $first = true; $cond = false; @@ -234,6 +241,7 @@ TEXT; $prefix .= " AND $equality"; } } + return $cond; }