(bug 44805) Set correct number separators for Northern Sami
[lhc/web/wiklou.git] / maintenance / populateFilearchiveSha1.php
index e9baef9..27e692d 100644 (file)
@@ -48,8 +48,14 @@ class PopulateFilearchiveSha1 extends LoggedUpdateMaintenance {
                $dbw = wfGetDB( DB_MASTER );
                $table = 'filearchive';
                $conds = array( 'fa_sha1' => '', 'fa_storage_key IS NOT NULL' );
+
+               if ( !$dbw->fieldExists( $table, 'fa_sha1', __METHOD__ ) ) {
+                       $this->output( "fa_sha1 column does not exist\n\n", true );
+                       return false;
+               }
+
                $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 +71,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 ),