26 require_once __DIR__ .
'/Maintenance.php';
38 parent::__construct();
39 $this->
addDescription(
'Copy jobs from one queue system to another.' );
40 $this->
addOption(
'src',
'Key to $wgJobQueueMigrationConfig for source',
true,
true );
41 $this->
addOption(
'dst',
'Key to $wgJobQueueMigrationConfig for destination',
true,
true );
42 $this->
addOption(
'type',
'Types of jobs to copy (use "all" for all)',
true,
true );
47 global $wgJobQueueMigrationConfig;
52 if ( !isset( $wgJobQueueMigrationConfig[$srcKey] ) ) {
53 $this->
fatalError(
"\$wgJobQueueMigrationConfig not set for '$srcKey'." );
54 } elseif ( !isset( $wgJobQueueMigrationConfig[$dstKey] ) ) {
55 $this->
fatalError(
"\$wgJobQueueMigrationConfig not set for '$dstKey'." );
58 $types = ( $this->
getOption(
'type' ) ===
'all' )
62 $dbDomain = WikiMap::getCurrentWikiDbDomain()->getId();
63 foreach ( $types as $type ) {
64 $baseConfig = [
'type' => $type,
'domain' => $dbDomain ];
68 [ $total, $totalOK ] = $this->
copyJobs( $src, $dst, $src->getAllQueuedJobs() );
69 $this->
output(
"Copied $totalOK/$total queued $type jobs.\n" );
71 [ $total, $totalOK ] = $this->
copyJobs( $src, $dst, $src->getAllDelayedJobs() );
72 $this->
output(
"Copied $totalOK/$total delayed $type jobs.\n" );
80 foreach ( $jobs as
$job ) {
85 $totalOK += count( $batch );
90 if ( count( $batch ) ) {
92 $totalOK += count( $batch );
96 return [ $total, $totalOK ];
101 require_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.
Class to handle enqueueing and running of background jobs.
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...
output( $out, $channel=null)
Throw some output to the user.
getServiceContainer()
Returns the main service container.
getBatchSize()
Returns batch size.
addDescription( $text)
Set the description text.
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.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
if(count( $args)< 1) $job