public function execute() {
global $wgTitle;
+ if ( wfReadOnly() ) {
+ $this->error( "Unable to run jobs; the wiki is in read-only mode.", 1 ); // die
+ }
+
if ( $this->hasOption( 'procs' ) ) {
$procs = intval( $this->getOption( 'procs' ) );
if ( $procs < 1 || $procs > 1000 ) {
$n = 0;
$group = JobQueueGroup::singleton();
+ // Handle any required periodic queue maintenance
+ $count = $group->executeReadyPeriodicTasks();
+ if ( $count > 0 ) {
+ $this->runJobsLog( "Executed $count periodic queue task(s)." );
+ }
+
do {
$job = ( $type === false )
- ? $group->pop() // job from any queue
+ ? $group->pop( JobQueueGroup::TYPE_DEFAULT, JobQueueGroup::USE_CACHE )
: $group->get( $type )->pop(); // job from a single queue
if ( $job ) { // found a job
// Perform the job (logging success/failure and runtime)...
$t = microtime( true );
$this->runJobsLog( $job->toString() . " STARTING" );
$status = $job->run();
- $group->ack( $job ); // done
+ if ( $status ) {
+ $group->ack( $job ); // done
+ }
$t = microtime( true ) - $t;
$timeMs = intval( $t * 1000 );
if ( !$status ) {
break;
}
// Don't let any slaves/backups fall behind...
- $group->get( $type )->waitForBackups();
+ $group->get( $job->getType() )->waitForBackups();
}
} while ( $job ); // stop when there are no jobs
}