X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2FpopulateRevisionLength.php;h=b73ac7f270da219b956756f6398a7a16f10ae023;hb=53c4665ed057ec3aabd862fbe2ba3ee49d5150f2;hp=4acc5790028eb4fa8a7f2d971b0cfd434b2577af;hpb=0f79beec8b1cf79bad8f7f7326ce417913abc009;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/populateRevisionLength.php b/maintenance/populateRevisionLength.php index 4acc579002..b73ac7f270 100644 --- a/maintenance/populateRevisionLength.php +++ b/maintenance/populateRevisionLength.php @@ -49,31 +49,36 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance { $this->error( "archive table does not exist", true ); } elseif ( !$db->fieldExists( 'revision', 'rev_len', __METHOD__ ) ) { $this->output( "rev_len column does not exist\n\n", true ); + return false; } $this->output( "Populating rev_len column\n" ); - $rev = $this->doLenUpdates( 'revision', 'rev_id', 'rev' ); + $rev = $this->doLenUpdates( 'revision', 'rev_id', 'rev', Revision::selectFields() ); $this->output( "Populating ar_len column\n" ); - $ar = $this->doLenUpdates( 'archive', 'ar_id', 'ar' ); + $ar = $this->doLenUpdates( 'archive', 'ar_id', 'ar', Revision::selectArchiveFields() ); + + $this->output( "rev_len and ar_len population complete " + . "[$rev revision rows, $ar archive rows].\n" ); - $this->output( "rev_len and ar_len population complete [$rev revision rows, $ar archive rows].\n" ); return true; } /** - * @param $table - * @param $idCol - * @param $prefix + * @param string $table + * @param string $idCol + * @param string $prefix + * @param array $fields * @return int */ - protected function doLenUpdates( $table, $idCol, $prefix ) { + protected function doLenUpdates( $table, $idCol, $prefix, $fields ) { $db = $this->getDB( DB_MASTER ); $start = $db->selectField( $table, "MIN($idCol)", false, __METHOD__ ); $end = $db->selectField( $table, "MAX($idCol)", false, __METHOD__ ); if ( !$start || !$end ) { $this->output( "...$table table seems to be empty.\n" ); + return 0; } @@ -81,9 +86,9 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance { $blockStart = intval( $start ); $blockEnd = intval( $start ) + $this->mBatchSize - 1; $count = 0; - $fields = Revision::selectFields(); + while ( $blockStart <= $end ) { - $this->output( "...doing rev_id from $blockStart to $blockEnd\n" ); + $this->output( "...doing $idCol from $blockStart to $blockEnd\n" ); $res = $db->select( $table, $fields, @@ -113,10 +118,10 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance { } /** - * @param $row - * @param $table - * @param $idCol - * @param $prefix + * @param stdClass $row + * @param string $table + * @param string $idCol + * @param string $prefix * @return bool */ protected function upgradeRow( $row, $table, $idCol, $prefix ) { @@ -131,6 +136,7 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance { # This should not happen, but sometimes does (bug 20757) $id = $row->$idCol; $this->output( "Content of $table $id unavailable!\n" ); + return false; }