X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/modifier.php?a=blobdiff_plain;f=maintenance%2FpopulateImageSha1.php;h=84b65ee7ac9835f09be32065d326429997fdf0fa;hb=9e34eeff23fdd46a8e9bddfbab39d45eab232827;hp=cc52239f31cceddeb32c70c20c465e1213628e8c;hpb=77a8bbd406de8194432bbc92ce0b781ba44b43bc;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/populateImageSha1.php b/maintenance/populateImageSha1.php index cc52239f31..84b65ee7ac 100644 --- a/maintenance/populateImageSha1.php +++ b/maintenance/populateImageSha1.php @@ -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" . @@ -71,32 +71,30 @@ class PopulateImageSha1 extends LoggedUpdateMaintenance { 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->fatalError( "No such file: $file" ); } $this->output( "Populating img_sha1 field for specified files\n" ); } else { if ( $this->hasOption( 'multiversiononly' ) ) { - $conds = array(); + $conds = []; $this->output( "Populating and recalculating img_sha1 field for versioned files\n" ); } elseif ( $force ) { - $conds = array(); + $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__ ); } } @@ -119,7 +117,7 @@ class PopulateImageSha1 extends LoggedUpdateMaintenance { $numRows = $res->numRows(); $i = 0; foreach ( $res as $row ) { - if ( $i % $this->mBatchSize == 0 ) { + if ( $i % $this->getBatchSize() == 0 ) { $this->output( sprintf( "Done %d of %d, %5.3f%% \r", $i, $numRows, $i / $numRows * 100 ) ); wfWaitForSlaves();