Improve output of refreshImageMetadata and refreshFileHeaders
authorGilles Dubuc <gilles@wikimedia.org>
Mon, 15 May 2017 21:16:35 +0000 (23:16 +0200)
committerGilles Dubuc <gdubuc@wikimedia.org>
Tue, 16 May 2017 07:13:36 +0000 (09:13 +0200)
Bug: T150741
Change-Id: Ie5f787fd77ecd31b8852d0f66de912baced4ca46

maintenance/refreshFileHeaders.php
maintenance/refreshImageMetadata.php

index f922055..b9b418c 100644 (file)
@@ -55,6 +55,13 @@ class RefreshFileHeaders extends Maintenance {
                        }
                        $res = $dbr->select( 'image', '*', $conds,
                                __METHOD__, [ 'LIMIT' => $this->mBatchSize, 'ORDER BY' => 'img_name ASC' ] );
+
+                       if ( $res->numRows() > 0 ) {
+                               $row1 = $res->current();
+                               $this->output( "Processing next {$res->numRows()} row(s) starting with {$row1->img_name}.\n" );
+                               $res->rewind();
+                       }
+
                        foreach ( $res as $row ) {
                                $file = $repo->newFileFromRow( $row );
                                $headers = $file->getContentHeaders();
@@ -74,7 +81,7 @@ class RefreshFileHeaders extends Maintenance {
                                ++$count;
                                $start = $row->img_name; // advance
                        }
-               } while ( $res->numRows() > 0 );
+               } while ( $res->numRows() === $this->mBatchSize );
 
                $this->output( "Done. Updated headers for $count file(s).\n" );
        }
index b557f3d..f6e9e9c 100644 (file)
@@ -135,10 +135,8 @@ class RefreshImageMetadata extends Maintenance {
 
                        if ( $res->numRows() > 0 ) {
                                $row1 = $res->current();
-                               $this->output( "Processing next {$this->mBatchSize} rows starting with {$row1->img_name}.\n" );
+                               $this->output( "Processing next {$res->numRows()} row(s) starting with {$row1->img_name}.\n" );
                                $res->rewind();
-                       } else {
-                               $this->error( "No images to process.", 4 );
                        }
 
                        foreach ( $res as $row ) {