Deprecating: Consolidating `progressive` & `constructive` buttons
[lhc/web/wiklou.git] / maintenance / populateImageSha1.php
index 575573b..51cc72a 100644 (file)
@@ -31,7 +31,7 @@ require_once __DIR__ . '/Maintenance.php';
 class PopulateImageSha1 extends LoggedUpdateMaintenance {
        public function __construct() {
                parent::__construct();
-               $this->mDescription = "Populate the img_sha1 field";
+               $this->addDescription( 'Populate the img_sha1 field' );
                $this->addOption( 'force', "Recalculate sha1 for rows that already have a value" );
                $this->addOption( 'multiversiononly', "Calculate only for files with several versions" );
                $this->addOption( 'method', "Use 'pipe' to pipe to mysql command line,\n" .
@@ -67,7 +67,7 @@ class PopulateImageSha1 extends LoggedUpdateMaintenance {
                $isRegen = ( $force || $file != '' ); // forced recalculation?
 
                $t = -microtime( true );
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                if ( $file != '' ) {
                        $res = $dbw->select(
                                'image',
@@ -77,11 +77,15 @@ class PopulateImageSha1 extends LoggedUpdateMaintenance {
                        );
                        if ( !$res ) {
                                $this->error( "No such file: $file", true );
+
                                return false;
                        }
                        $this->output( "Populating img_sha1 field for specified files\n" );
                } else {
-                       if ( $force ) {
+                       if ( $this->hasOption( 'multiversiononly' ) ) {
+                               $conds = array();
+                               $this->output( "Populating and recalculating img_sha1 field for versioned files\n" );
+                       } elseif ( $force ) {
                                $conds = array();
                                $this->output( "Populating and recalculating img_sha1 field\n" );
                        } else {