15require_once __DIR__ .
'/Maintenance.php';
28 parent::__construct();
29 $this->
addDescription(
'Copy jobs from one queue system to another.' );
30 $this->
addOption(
'src',
'Key to $wgJobQueueMigrationConfig for source',
true,
true );
31 $this->
addOption(
'dst',
'Key to $wgJobQueueMigrationConfig for destination',
true,
true );
32 $this->
addOption(
'type',
'Types of jobs to copy (use "all" for all)',
true,
true );
37 global $wgJobQueueMigrationConfig;
42 if ( !isset( $wgJobQueueMigrationConfig[$srcKey] ) ) {
43 $this->
fatalError(
"\$wgJobQueueMigrationConfig not set for '$srcKey'." );
44 } elseif ( !isset( $wgJobQueueMigrationConfig[$dstKey] ) ) {
45 $this->
fatalError(
"\$wgJobQueueMigrationConfig not set for '$dstKey'." );
48 $types = ( $this->
getOption(
'type' ) ===
'all' )
52 $dbDomain = WikiMap::getCurrentWikiDbDomain()->getId();
53 foreach ( $types as $type ) {
54 $baseConfig = [
'type' => $type,
'domain' => $dbDomain ];
55 $src = JobQueue::factory( $baseConfig + $wgJobQueueMigrationConfig[$srcKey] );
56 $dst = JobQueue::factory( $baseConfig + $wgJobQueueMigrationConfig[$dstKey] );
59 $this->
output(
"Copied $totalOK/$total queued $type jobs.\n" );
62 $this->
output(
"Copied $totalOK/$total delayed $type jobs.\n" );
70 foreach ( $jobs as
$job ) {
75 $totalOK += count( $batch );
80 if ( count( $batch ) ) {
82 $totalOK += count( $batch );
86 return [ $total, $totalOK ];
92require_once RUN_MAINTENANCE_IF_MAIN;
Copy all jobs from one job queue system to another.
execute()
Do the actual work.
copyJobs(JobQueue $src, JobQueue $dst, iterable $jobs)
__construct()
Default constructor.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
getBatchSize()
Returns batch size.
output( $out, $channel=null)
Throw some output to the user.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
getServiceContainer()
Returns the main service container.
addDescription( $text)
Set the description text.
if(count( $args)< 1) $job