13use Wikimedia\Timestamp\TimestampFormat as TS;
16require_once __DIR__ .
'/Maintenance.php';
26 parent::__construct();
27 $this->
addDescription(
'Perform administrative tasks on a job queue' );
28 $this->
addOption(
'type',
'Job type',
true,
true );
29 $this->
addOption(
'action',
'Queue operation ("delete", "repush-abandoned")',
true,
true );
38 $queue = $group->get( $type );
40 if ( $action ===
'delete' ) {
41 $this->
delete( $queue );
42 } elseif ( $action ===
'repush-abandoned' ) {
43 $this->repushAbandoned( $queue );
45 $this->
fatalError(
"Invalid action '$action'." );
49 private function delete(
JobQueue $queue ) {
50 $this->
output(
"Queue has {$queue->getSize()} job(s); deleting...\n" );
52 $this->
output(
"Done; current size is {$queue->getSize()} job(s).\n" );
55 private function repushAbandoned(
JobQueue $queue ) {
57 $key = $cache->makeGlobalKey(
'last-job-repush', $queue->
getDomain(), $queue->
getType() );
60 $lastRepushTime = $cache->get( $key );
61 if ( $lastRepushTime ===
false ) {
65 $this->
output(
"Last re-push time: $lastRepushTime; current time: $now\n" );
84 $cache->set( $key, $now );
86 $this->
output(
"Re-pushed $count job(s) [$skipped skipped].\n" );
92require_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.
Maintenance script that handles managing job queue admin tasks (re-push, delete, ....
execute()
Do the actual work.
__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