diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:12:12 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:12:12 -0400 |
commit | c9aa36da061816dee256a979c2ff8d2ee41824d9 (patch) | |
tree | 29f7002b80ee984b488bd047dbbd80b36bf892e9 /maintenance/populateImageSha1.php | |
parent | b4274e0e33eafb5e9ead9d949ebf031a9fb8363b (diff) | |
parent | d1ba966140d7a60cd5ae4e8667ceb27c1a138592 (diff) |
Merge branch 'archwiki'
# Conflicts:
# skins/ArchLinux.php
# skins/ArchLinux/archlogo.gif
Diffstat (limited to 'maintenance/populateImageSha1.php')
-rw-r--r-- | maintenance/populateImageSha1.php | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/maintenance/populateImageSha1.php b/maintenance/populateImageSha1.php index 126d22d9..e9123aa3 100644 --- a/maintenance/populateImageSha1.php +++ b/maintenance/populateImageSha1.php @@ -33,9 +33,15 @@ class PopulateImageSha1 extends LoggedUpdateMaintenance { parent::__construct(); $this->mDescription = "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() { @@ -47,7 +53,7 @@ class PopulateImageSha1 extends LoggedUpdateMaintenance { } public function execute() { - if ( $this->getOption( 'file' ) ) { + if ( $this->getOption( 'file' ) || $this->hasOption( 'multiversiononly' ) ) { $this->doDBUpdates(); // skip update log checks/saves } else { parent::execute(); @@ -71,18 +77,27 @@ 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 { $conds = array( 'img_sha1' => '' ); $this->output( "Populating img_sha1 field\n" ); } - $res = $dbw->select( 'image', array( 'img_name' ), $conds, __METHOD__ ); + if ( $this->hasOption( 'multiversiononly' ) ) { + $res = $dbw->select( 'oldimage', + array( 'img_name' => 'DISTINCT(oi_name)' ), $conds, __METHOD__ ); + } else { + $res = $dbw->select( 'image', array( 'img_name' ), $conds, __METHOD__ ); + } } $imageTable = $dbw->tableName( 'image' ); @@ -109,10 +124,12 @@ class PopulateImageSha1 extends LoggedUpdateMaintenance { "Done %d of %d, %5.3f%% \r", $i, $numRows, $i / $numRows * 100 ) ); wfWaitForSlaves(); } + $file = wfLocalFile( $row->img_name ); if ( !$file ) { continue; } + // Upgrade the current file version... $sha1 = $file->getRepo()->getFileSha1( $file->getPath() ); if ( strval( $sha1 ) !== '' ) { // file on disk and hashed properly |