jenkins-bot has submitted this change and it was merged. Change subject: Fix populateRevisionLength.php so it's not trying to select revision fields from the archive table (they won't exist!) ......................................................................
Fix populateRevisionLength.php so it's not trying to select revision fields from the archive table (they won't exist!) Follows up https://gerrit.wikimedia.org/r/#/c/54111/ Change-Id: Ie161a08097a2cd3393d69574263cfe78e4329bb4 --- M includes/Revision.php M maintenance/populateRevisionLength.php 2 files changed, 42 insertions(+), 11 deletions(-) Approvals: saper: Looks good to me, but someone else must approve Chad: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/Revision.php b/includes/Revision.php index 233eac0..4446173 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -434,6 +434,36 @@ } /** + * Return the list of revision fields that should be selected to create + * a new revision from an archive row. + * @return array + */ + public static function selectArchiveFields() { + global $wgContentHandlerUseDB; + $fields = array( + 'ar_id', + 'ar_page_id', + 'ar_rev_id', + 'ar_text_id', + 'ar_timestamp', + 'ar_comment', + 'ar_user_text', + 'ar_user', + 'ar_minor_edit', + 'ar_deleted', + 'ar_len', + 'ar_parent_id', + 'ar_sha1', + ); + + if ( $wgContentHandlerUseDB ) { + $fields[] = 'ar_content_format'; + $fields[] = 'ar_content_model'; + } + return $fields; + } + + /** * Return the list of text fields that should be selected to read the * revision text * @return array diff --git a/maintenance/populateRevisionLength.php b/maintenance/populateRevisionLength.php index 4acc579..042790f 100644 --- a/maintenance/populateRevisionLength.php +++ b/maintenance/populateRevisionLength.php @@ -53,22 +53,23 @@ } $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" ); 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__ ); @@ -81,9 +82,9 @@ $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, @@ -114,9 +115,9 @@ /** * @param $row - * @param $table - * @param $idCol - * @param $prefix + * @param string $table + * @param string $idCol + * @param string $prefix * @return bool */ protected function upgradeRow( $row, $table, $idCol, $prefix ) { -- To view, visit https://gerrit.wikimedia.org/r/92432 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie161a08097a2cd3393d69574263cfe78e4329bb4 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Reedy <[email protected]> Gerrit-Reviewer: Chad <[email protected]> Gerrit-Reviewer: Reedy <[email protected]> Gerrit-Reviewer: jenkins-bot Gerrit-Reviewer: saper <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
