Index: trunk/phase3/maintenance/populateRevisionSha1.php |
— | — | @@ -104,7 +104,7 @@ |
105 | 105 | $updateSize = 0; |
106 | 106 | $db->begin(); |
107 | 107 | foreach ( $res as $row ) { |
108 | | - if ( $this->upgradeRow( $row, 'archive', 'ar_timestamp', 'ar' ) ) { |
| 108 | + if ( $this->upgradeLegacyArchiveRow( $row ) ) { |
109 | 109 | ++$count; |
110 | 110 | } |
111 | 111 | if ( ++$updateSize >= 100 ) { |
— | — | @@ -139,6 +139,31 @@ |
140 | 140 | return true; |
141 | 141 | } |
142 | 142 | } |
| 143 | + |
| 144 | + protected function upgradeLegacyArchiveRow( $row ) { |
| 145 | + $db = $this->getDB( DB_MASTER ); |
| 146 | + $rev = Revision::newFromArchiveRow( $row ); |
| 147 | + $text = $rev->getRawText(); |
| 148 | + if ( !is_string( $text ) ) { |
| 149 | + # This should not happen, but sometimes does (bug 20757) |
| 150 | + $this->output( "Text of revision with timestamp {$row->ar_timestamp} unavailable!\n" ); |
| 151 | + return false; |
| 152 | + } else { |
| 153 | + # Archive table as no PK, but (NS,title,time) should be near unique. |
| 154 | + # Any duplicates on those should also have duplicated text anyway. |
| 155 | + $db->update( 'archive', |
| 156 | + array( 'ar_sha1' => Revision::base36Sha1( $text ) ), |
| 157 | + array( |
| 158 | + 'ar_namespace' => $row->ar_namespace, |
| 159 | + 'ar_title' => $row->ar_title, |
| 160 | + 'ar_timestamp' => $row->ar_timestamp, |
| 161 | + 'ar_len' => $row->ar_len // extra sanity |
| 162 | + ), |
| 163 | + __METHOD__ |
| 164 | + ); |
| 165 | + return true; |
| 166 | + } |
| 167 | + } |
143 | 168 | } |
144 | 169 | |
145 | 170 | $maintClass = "PopulateRevisionSha1"; |