24 require_once __DIR__ .
'/Maintenance.php';
33 parent::__construct();
34 $this->
addDescription(
'Perform administrative tasks on a job queue' );
35 $this->
addOption(
'type',
'Job type',
true,
true );
36 $this->
addOption(
'action',
'Queue operation ("delete", "repush-abandoned")',
true,
true );
45 $queue = $group->get( $type );
47 if ( $action ===
'delete' ) {
48 $this->
delete( $queue );
49 } elseif ( $action ===
'repush-abandoned' ) {
50 $this->repushAbandoned( $queue );
52 $this->
fatalError(
"Invalid action '$action'." );
56 private function delete(
JobQueue $queue ) {
57 $this->
output(
"Queue has {$queue->getSize()} job(s); deleting...\n" );
59 $this->
output(
"Done; current size is {$queue->getSize()} job(s).\n" );
62 private function repushAbandoned(
JobQueue $queue ) {
64 $key = $cache->makeGlobalKey(
'last-job-repush', $queue->
getDomain(), $queue->
getType() );
67 $lastRepushTime = $cache->get( $key );
68 if ( $lastRepushTime ===
false ) {
72 $this->
output(
"Last re-push time: $lastRepushTime; current time: $now\n" );
91 $cache->set( $key, $now );
93 $this->
output(
"Re-pushed $count job(s) [$skipped skipped].\n" );
98 require_once RUN_MAINTENANCE_IF_MAIN;
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
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.
delete()
Delete all unclaimed and delayed jobs from the queue.
getAllAbandonedJobs()
Get an iterator to traverse over all abandoned jobs in this queue.
Class to both describe a background job and handle jobs.
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.
Maintenance script that handles managing job queue admin tasks (re-push, delete, ....
execute()
Do the actual work.
__construct()
Default constructor.
static getInstance( $id)
Get a cached instance of the specified type of cache object.
if(count( $args)< 1) $job