35 parent::__construct();
36 $this->
addDescription(
'Perform administrative tasks on a job queue' );
37 $this->
addOption(
'type',
'Job type',
true,
true );
38 $this->
addOption(
'action',
'Queue operation ("delete", "repush-abandoned")',
true,
true );
47 $queue = $group->get( $type );
49 if ( $action ===
'delete' ) {
50 $this->
delete( $queue );
51 } elseif ( $action ===
'repush-abandoned' ) {
52 $this->repushAbandoned( $queue );
54 $this->
fatalError(
"Invalid action '$action'." );
58 private function delete(
JobQueue $queue ) {
59 $this->
output(
"Queue has {$queue->getSize()} job(s); deleting...\n" );
61 $this->
output(
"Done; current size is {$queue->getSize()} job(s).\n" );
64 private function repushAbandoned(
JobQueue $queue ) {
65 $cache = MediaWikiServices::getInstance()->getObjectCacheFactory()->getInstance(
CACHE_DB );
66 $key = $cache->makeGlobalKey(
'last-job-repush', $queue->
getDomain(), $queue->
getType() );
69 $lastRepushTime = $cache->get( $key );
70 if ( $lastRepushTime ===
false ) {
74 $this->
output(
"Last re-push time: $lastRepushTime; current time: $now\n" );
93 $cache->set( $key, $now );
95 $this->
output(
"Re-pushed $count job(s) [$skipped skipped].\n" );
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.
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.