MediaWiki REL1_39
NullJob.php
Go to the documentation of this file.
1<?php
25
49class NullJob extends Job implements GenericParameterJob {
53 public function __construct( array $params ) {
54 parent::__construct( 'null', $params );
55 if ( !isset( $this->params['lives'] ) ) {
56 $this->params['lives'] = 1;
57 }
58 if ( !isset( $this->params['usleep'] ) ) {
59 $this->params['usleep'] = 0;
60 }
61 $this->removeDuplicates = !empty( $this->params['removeDuplicates'] );
62 }
63
64 public function run() {
65 if ( $this->params['usleep'] > 0 ) {
66 usleep( $this->params['usleep'] );
67 }
68 if ( $this->params['lives'] > 1 ) {
69 $params = $this->params;
70 $params['lives']--;
71 $job = new self( $params );
72 MediaWikiServices::getInstance()->getJobQueueGroup()->push( $job );
73 }
74
75 return true;
76 }
77}
Class to both describe a background job and handle jobs.
Definition Job.php:39
array $params
Array of job parameters.
Definition Job.php:44
Service locator for MediaWiki core services.
Degenerate job that does nothing, but can optionally replace itself in the queue and/or sleep for a b...
Definition NullJob.php:49
run()
Run the job.
Definition NullJob.php:64
__construct(array $params)
Definition NullJob.php:53
Interface for generic jobs only uses the parameters field and are JSON serializable.
if(count( $args)< 1) $job