From b4704adf09f0f93fe863b27811f2f4dc8a8da116 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 20 Feb 2012 11:00:56 +0000 Subject: [PATCH] r111795: Split out upgradeLegacyArchiveRow() function and added NS/title to condition. The $idCol var was misleading as obviously ar_timestamp is not unique. --- maintenance/populateRevisionSha1.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/maintenance/populateRevisionSha1.php b/maintenance/populateRevisionSha1.php index 144133c3a7..7cb137dad0 100644 --- a/maintenance/populateRevisionSha1.php +++ b/maintenance/populateRevisionSha1.php @@ -104,7 +104,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { $updateSize = 0; $db->begin(); foreach ( $res as $row ) { - if ( $this->upgradeRow( $row, 'archive', 'ar_timestamp', 'ar' ) ) { + if ( $this->upgradeLegacyArchiveRow( $row ) ) { ++$count; } if ( ++$updateSize >= 100 ) { @@ -139,6 +139,31 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { return true; } } + + protected function upgradeLegacyArchiveRow( $row ) { + $db = $this->getDB( DB_MASTER ); + $rev = Revision::newFromArchiveRow( $row ); + $text = $rev->getRawText(); + if ( !is_string( $text ) ) { + # This should not happen, but sometimes does (bug 20757) + $this->output( "Text of revision with timestamp {$row->ar_timestamp} unavailable!\n" ); + return false; + } else { + # Archive table as no PK, but (NS,title,time) should be near unique. + # Any duplicates on those should also have duplicated text anyway. + $db->update( 'archive', + array( 'ar_sha1' => Revision::base36Sha1( $text ) ), + array( + 'ar_namespace' => $row->ar_namespace, + 'ar_title' => $row->ar_title, + 'ar_timestamp' => $row->ar_timestamp, + 'ar_len' => $row->ar_len // extra sanity + ), + __METHOD__ + ); + return true; + } + } } $maintClass = "PopulateRevisionSha1"; -- 2.20.1