Merge "Fix small typo in comment"
[lhc/web/wiklou.git] / maintenance / populateRevisionSha1.php
index 2266a3f..1d8e4c8 100644 (file)
@@ -102,7 +102,8 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
        protected function doSha1LegacyUpdates() {
                $count = 0;
                $db = $this->getDB( DB_MASTER );
-               $res = $db->select( 'archive', '*', array( 'ar_rev_id IS NULL' ), __METHOD__ );
+               $res = $db->select( 'archive', '*',
+                       array( 'ar_rev_id IS NULL', 'ar_sha1' => '' ), __METHOD__ );
 
                $updateSize = 0;
                $db->begin( __METHOD__ );
@@ -131,12 +132,15 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
         */
        protected function upgradeRow( $row, $table, $idCol, $prefix ) {
                $db = $this->getDB( DB_MASTER );
-               if ( $table === 'archive' ) {
-                       $rev = Revision::newFromArchiveRow( $row );
-               } else {
-                       $rev = new Revision( $row );
+               try {
+                       $rev = ( $table === 'archive' )
+                               ? Revision::newFromArchiveRow( $row )
+                               : new Revision( $row );
+                       $text = $rev->getRawText();
+               } catch ( MWException $e ) {
+                       $this->output( "Text of revision with {$idCol}={$row->$idCol} unavailable!\n" );
+                       return false; // bug 22624?
                }
-               $text = $rev->getRawText();
                if ( !is_string( $text ) ) {
                        # This should not happen, but sometimes does (bug 20757)
                        $this->output( "Text of revision with {$idCol}={$row->$idCol} unavailable!\n" );
@@ -160,6 +164,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
                try {
                        $rev = Revision::newFromArchiveRow( $row );
                } catch ( MWException $e ) {
+                       $this->output( "Text of revision with timestamp {$row->ar_timestamp} unavailable!\n" );
                        return false; // bug 22624?
                }
                $text = $rev->getRawText();