Seems we have error conditions where fa_storage_key == ''
authorReedy <reedy@wikimedia.org>
Thu, 25 Oct 2012 13:27:49 +0000 (14:27 +0100)
committerReedy <reedy@wikimedia.org>
Thu, 25 Oct 2012 13:27:49 +0000 (14:27 +0100)
continue!

Change-Id: I28a06bf6a806fd4db44af6822ca3cd93747481fb

maintenance/populateFilearchiveSha1.php

index e9baef9..6c57fde 100644 (file)
@@ -49,7 +49,7 @@ class PopulateFilearchiveSha1 extends LoggedUpdateMaintenance {
                $table = 'filearchive';
                $conds = array( 'fa_sha1' => '', 'fa_storage_key IS NOT NULL' );
                $this->output( "Populating fa_sha1 field from fa_storage_key\n" );
-               $endId = $dbw->selectField( $table, 'MAX(fa_id)', false, __METHOD__ );\r
+               $endId = $dbw->selectField( $table, 'MAX(fa_id)', false, __METHOD__ );
 
                $batchSize = $this->mBatchSize;
                $done = 0;
@@ -65,6 +65,10 @@ class PopulateFilearchiveSha1 extends LoggedUpdateMaintenance {
 
                        $i = 0;
                        foreach ( $res as $row ) {
+                               if ( $row->fa_storage_key == '' ) {
+                                       // Revision was missing pre-deletion
+                                       continue;
+                               }
                                $sha1 = LocalRepo::getHashFromKey( $row->fa_storage_key );
                                $dbw->update( $table,
                                        array( 'fa_sha1' => $sha1 ),