X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=maintenance%2FpopulateImageSha1.php;h=b581d6614c82bd289b7ef366a9614d38cbcd2a16;hb=cbac334f116c6546c422a67ce99d2a56eb792d30;hp=4964bf116ca6f433668a74918af689d44ba573aa;hpb=f0d1e12ffa186654a2f262c2ac87944feec81eb5;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/populateImageSha1.php b/maintenance/populateImageSha1.php index 4964bf116c..b581d6614c 100644 --- a/maintenance/populateImageSha1.php +++ b/maintenance/populateImageSha1.php @@ -31,12 +31,17 @@ 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" . "\t\tdefault uses Database class", false, true ); - $this->addOption( 'file', 'Fix for a specific file, without File: namespace prefixed', false, true ); + $this->addOption( + 'file', + 'Fix for a specific file, without File: namespace prefixed', + false, + true + ); } protected function getUpdateKey() { @@ -62,32 +67,36 @@ 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', - array( 'img_name' ), - array( 'img_name' => $file ), + [ 'img_name' ], + [ 'img_name' => $file ], __METHOD__ ); if ( !$res ) { $this->error( "No such file: $file", true ); + return false; } $this->output( "Populating img_sha1 field for specified files\n" ); } else { - if ( $force ) { - $conds = array(); + if ( $this->hasOption( 'multiversiononly' ) ) { + $conds = []; + $this->output( "Populating and recalculating img_sha1 field for versioned files\n" ); + } elseif ( $force ) { + $conds = []; $this->output( "Populating and recalculating img_sha1 field\n" ); } else { - $conds = array( 'img_sha1' => '' ); + $conds = [ 'img_sha1' => '' ]; $this->output( "Populating img_sha1 field\n" ); } if ( $this->hasOption( 'multiversiononly' ) ) { $res = $dbw->select( 'oldimage', - array( 'img_name' => 'DISTINCT(oi_name)' ), $conds, __METHOD__ ); + [ 'img_name' => 'DISTINCT(oi_name)' ], $conds, __METHOD__ ); } else { - $res = $dbw->select( 'image', array( 'img_name' ), $conds, __METHOD__ ); + $res = $dbw->select( 'image', [ 'img_name' ], $conds, __METHOD__ ); } }