28require_once __DIR__ .
'/Maintenance.php';
41 parent::__construct();
42 $this->
addDescription(
'Copy jobs from one queue system to another.' );
43 $this->
addOption(
'src',
'Key to $wgJobQueueMigrationConfig for source',
true,
true );
44 $this->
addOption(
'dst',
'Key to $wgJobQueueMigrationConfig for destination',
true,
true );
45 $this->
addOption(
'type',
'Types of jobs to copy (use "all" for all)',
true,
true );
50 global $wgJobQueueMigrationConfig;
55 if ( !isset( $wgJobQueueMigrationConfig[$srcKey] ) ) {
56 $this->
fatalError(
"\$wgJobQueueMigrationConfig not set for '$srcKey'." );
57 } elseif ( !isset( $wgJobQueueMigrationConfig[$dstKey] ) ) {
58 $this->
fatalError(
"\$wgJobQueueMigrationConfig not set for '$dstKey'." );
61 $types = ( $this->
getOption(
'type' ) ===
'all' )
65 $dbDomain = WikiMap::getCurrentWikiDbDomain()->getId();
66 foreach ( $types as $type ) {
67 $baseConfig = [
'type' => $type,
'domain' => $dbDomain ];
71 [ $total, $totalOK ] = $this->
copyJobs( $src, $dst, $src->getAllQueuedJobs() );
72 $this->
output(
"Copied $totalOK/$total queued $type jobs.\n" );
74 [ $total, $totalOK ] = $this->
copyJobs( $src, $dst, $src->getAllDelayedJobs() );
75 $this->
output(
"Copied $totalOK/$total delayed $type jobs.\n" );
83 foreach ( $jobs as
$job ) {
88 $totalOK += count( $batch );
93 if ( count( $batch ) ) {
95 $totalOK += count( $batch );
99 return [ $total, $totalOK ];
105require_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, $jobs)
__construct()
Default constructor.
Base class for queueing and running background jobs from a storage backend.
waitForBackups()
Wait for any replica DBs or backup servers to catch up.
push( $jobs, $flags=0)
Push one or more jobs into the queue.
static factory(array $params)
Get a job queue object of the specified type.
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