X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FcopyJobQueue.php;h=7dd40b839fe705efbe0f226cd28e4f8e7b7bb868;hb=0c341778ac7e3750f6709d39daa3225127814187;hp=c91264ce2131e008109c3f8c317438edd75e5ad4;hpb=ea4340e126eb2657cc878af74d53b9991844fb6b;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/copyJobQueue.php b/maintenance/copyJobQueue.php index c91264ce21..7dd40b839f 100644 --- a/maintenance/copyJobQueue.php +++ b/maintenance/copyJobQueue.php @@ -21,7 +21,7 @@ * @ingroup Maintenance */ -require_once( __DIR__ . '/Maintenance.php' ); +require_once __DIR__ . '/Maintenance.php'; /** * Copy all jobs from one job queue system to another. @@ -34,7 +34,7 @@ require_once( __DIR__ . '/Maintenance.php' ); class CopyJobQueue extends Maintenance { public function __construct() { parent::__construct(); - $this->mDescription = "Copy jobs from one queue system to another."; + $this->addDescription( 'Copy jobs from one queue system to another.' ); $this->addOption( 'src', 'Key to $wgJobQueueMigrationConfig for source', true, true ); $this->addOption( 'dst', 'Key to $wgJobQueueMigrationConfig for destination', true, true ); $this->addOption( 'type', 'Types of jobs to copy (use "all" for all)', true, true ); @@ -48,17 +48,17 @@ class CopyJobQueue extends Maintenance { $dstKey = $this->getOption( 'dst' ); if ( !isset( $wgJobQueueMigrationConfig[$srcKey] ) ) { - $this->error( "\$wgJobQueueMigrationConfig not set for '$srcKey'.", 1 ); + $this->fatalError( "\$wgJobQueueMigrationConfig not set for '$srcKey'." ); } elseif ( !isset( $wgJobQueueMigrationConfig[$dstKey] ) ) { - $this->error( "\$wgJobQueueMigrationConfig not set for '$dstKey'.", 1 ); + $this->fatalError( "\$wgJobQueueMigrationConfig not set for '$dstKey'." ); } $types = ( $this->getOption( 'type' ) === 'all' ) ? JobQueueGroup::singleton()->getQueueTypes() - : array( $this->getOption( 'type' ) ); + : [ $this->getOption( 'type' ) ]; foreach ( $types as $type ) { - $baseConfig = array( 'type' => $type, 'wiki' => wfWikiID() ); + $baseConfig = [ 'type' => $type, 'wiki' => wfWikiID() ]; $src = JobQueue::factory( $baseConfig + $wgJobQueueMigrationConfig[$srcKey] ); $dst = JobQueue::factory( $baseConfig + $wgJobQueueMigrationConfig[$dstKey] ); @@ -73,25 +73,24 @@ class CopyJobQueue extends Maintenance { protected function copyJobs( JobQueue $src, JobQueue $dst, $jobs ) { $total = 0; $totalOK = 0; - $batch = array(); + $batch = []; foreach ( $jobs as $job ) { ++$total; $batch[] = $job; - if ( count( $batch ) >= $this->mBatchSize ) { - if ( $dst->push( $batch ) ) { - $totalOK += count( $batch ); - } - $batch = array(); + if ( count( $batch ) >= $this->getBatchSize() ) { + $dst->push( $batch ); + $totalOK += count( $batch ); + $batch = []; $dst->waitForBackups(); } } if ( count( $batch ) ) { - if ( $dst->push( $batch ) ) { - $totalOK += count( $batch ); - } + $dst->push( $batch ); + $totalOK += count( $batch ); $dst->waitForBackups(); } - return array( $total, $totalOK ); + + return [ $total, $totalOK ]; } }