dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
phpcs: More require/include is not a function
[lhc/web/wiklou.git]
/
maintenance
/
populateFilearchiveSha1.php
diff --git
a/maintenance/populateFilearchiveSha1.php
b/maintenance/populateFilearchiveSha1.php
index
e9baef9
..
c579d4f
100644
(file)
--- a/
maintenance/populateFilearchiveSha1.php
+++ b/
maintenance/populateFilearchiveSha1.php
@@
-21,7
+21,7
@@
* @ingroup Maintenance
*/
* @ingroup Maintenance
*/
-require_once
( dirname( __FILE__ ) . '/Maintenance.php' )
;
+require_once
dirname( __FILE__ ) . '/Maintenance.php'
;
/**
* Maintenance script to populate the fa_sha1 field.
/**
* Maintenance script to populate the fa_sha1 field.
@@
-48,8
+48,14
@@
class PopulateFilearchiveSha1 extends LoggedUpdateMaintenance {
$dbw = wfGetDB( DB_MASTER );
$table = 'filearchive';
$conds = array( 'fa_sha1' => '', 'fa_storage_key IS NOT NULL' );
$dbw = wfGetDB( DB_MASTER );
$table = 'filearchive';
$conds = array( 'fa_sha1' => '', 'fa_storage_key IS NOT NULL' );
+
+ if ( !$dbw->fieldExists( $table, 'fa_sha1', __METHOD__ ) ) {
+ $this->output( "fa_sha1 column does not exist\n\n", true );
+ return false;
+ }
+
$this->output( "Populating fa_sha1 field from fa_storage_key\n" );
$this->output( "Populating fa_sha1 field from fa_storage_key\n" );
- $endId = $dbw->selectField( $table, 'MAX(fa_id)', false, __METHOD__ );
\r
+ $endId = $dbw->selectField( $table, 'MAX(fa_id)', false, __METHOD__ );
$batchSize = $this->mBatchSize;
$done = 0;
$batchSize = $this->mBatchSize;
$done = 0;
@@
-65,6
+71,10
@@
class PopulateFilearchiveSha1 extends LoggedUpdateMaintenance {
$i = 0;
foreach ( $res as $row ) {
$i = 0;
foreach ( $res as $row ) {
+ if ( $row->fa_storage_key == '' ) {
+ // Revision was missing pre-deletion
+ continue;
+ }
$sha1 = LocalRepo::getHashFromKey( $row->fa_storage_key );
$dbw->update( $table,
array( 'fa_sha1' => $sha1 ),
$sha1 = LocalRepo::getHashFromKey( $row->fa_storage_key );
$dbw->update( $table,
array( 'fa_sha1' => $sha1 ),
@@
-76,7
+86,7
@@
class PopulateFilearchiveSha1 extends LoggedUpdateMaintenance {
}
$done += $i;
}
$done += $i;
- if( $i !== $batchSize ) {
+ if
( $i !== $batchSize ) {
break;
}
break;
}
@@
-84,7
+94,7
@@
class PopulateFilearchiveSha1 extends LoggedUpdateMaintenance {
$this->output( sprintf(
"id %d done (up to %d), %5.3f%% \r", $lastId, $endId, $lastId / $endId * 100 ) );
wfWaitForSlaves();
$this->output( sprintf(
"id %d done (up to %d), %5.3f%% \r", $lastId, $endId, $lastId / $endId * 100 ) );
wfWaitForSlaves();
- } while( true );
+ } while
( true );
$processingTime = microtime( true ) - $startTime;
$this->output( sprintf( "\nDone %d files in %.1f seconds\n", $done, $processingTime ) );
$processingTime = microtime( true ) - $startTime;
$this->output( sprintf( "\nDone %d files in %.1f seconds\n", $done, $processingTime ) );
@@
-94,4
+104,4
@@
class PopulateFilearchiveSha1 extends LoggedUpdateMaintenance {
}
$maintClass = "PopulateFilearchiveSha1";
}
$maintClass = "PopulateFilearchiveSha1";
-require_once
( RUN_MAINTENANCE_IF_MAIN )
;
+require_once
RUN_MAINTENANCE_IF_MAIN
;