MediaWiki  1.34.0
NullJob.php
Go to the documentation of this file.
1 <?php
47 class NullJob extends Job implements GenericParameterJob {
51  function __construct( array $params ) {
52  parent::__construct( 'null', $params );
53  if ( !isset( $this->params['lives'] ) ) {
54  $this->params['lives'] = 1;
55  }
56  if ( !isset( $this->params['usleep'] ) ) {
57  $this->params['usleep'] = 0;
58  }
59  $this->removeDuplicates = !empty( $this->params['removeDuplicates'] );
60  }
61 
62  public function run() {
63  if ( $this->params['usleep'] > 0 ) {
64  usleep( $this->params['usleep'] );
65  }
66  if ( $this->params['lives'] > 1 ) {
68  $params['lives']--;
69  $job = new self( $params );
70  JobQueueGroup::singleton()->push( $job );
71  }
72 
73  return true;
74  }
75 }
NullJob
Degenerate job that does nothing, but can optionally replace itself in the queue and/or sleep for a b...
Definition: NullJob.php:47
Job\$params
array $params
Array of job parameters.
Definition: Job.php:35
NullJob\__construct
__construct(array $params)
Definition: NullJob.php:51
Job
Class to both describe a background job and handle jobs.
Definition: Job.php:30
JobQueueGroup\singleton
static singleton( $domain=false)
Definition: JobQueueGroup.php:70
$job
if(count( $args)< 1) $job
Definition: recompressTracked.php:50
NullJob\run
run()
Run the job.
Definition: NullJob.php:62
GenericParameterJob
Interface for generic jobs only uses the parameters field and are JSON serializable.
Definition: GenericParameterJob.php:29