29require_once __DIR__ .
'/Maintenance.php';
39 parent::__construct();
40 $this->
addDescription(
'Perform administrative tasks on a job queue' );
41 $this->
addOption(
'type',
'Job type',
true,
true );
42 $this->
addOption(
'action',
'Queue operation ("delete", "repush-abandoned")',
true,
true );
51 $queue = $group->get( $type );
53 if ( $action ===
'delete' ) {
54 $this->
delete( $queue );
55 } elseif ( $action ===
'repush-abandoned' ) {
56 $this->repushAbandoned( $queue );
58 $this->
fatalError(
"Invalid action '$action'." );
62 private function delete(
JobQueue $queue ) {
63 $this->
output(
"Queue has {$queue->getSize()} job(s); deleting...\n" );
65 $this->
output(
"Done; current size is {$queue->getSize()} job(s).\n" );
68 private function repushAbandoned(
JobQueue $queue ) {
70 $key = $cache->makeGlobalKey(
'last-job-repush', $queue->
getDomain(), $queue->
getType() );
73 $lastRepushTime = $cache->get( $key );
74 if ( $lastRepushTime ===
false ) {
78 $this->
output(
"Last re-push time: $lastRepushTime; current time: $now\n" );
97 $cache->set( $key, $now );
99 $this->
output(
"Re-pushed $count job(s) [$skipped skipped].\n" );
105require_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