MediaWiki master
NullJob.php
Go to the documentation of this file.
1<?php
8
12
40class NullJob extends Job implements GenericParameterJob {
44 public function __construct( array $params ) {
45 parent::__construct( 'null', $params );
46 if ( !isset( $this->params['lives'] ) ) {
47 $this->params['lives'] = 1;
48 }
49 if ( !isset( $this->params['usleep'] ) ) {
50 $this->params['usleep'] = 0;
51 }
52 $this->removeDuplicates = !empty( $this->params['removeDuplicates'] );
53 }
54
56 public function run() {
57 if ( $this->params['usleep'] > 0 ) {
58 usleep( $this->params['usleep'] );
59 }
60 if ( $this->params['lives'] > 1 ) {
62 $params['lives']--;
63 $job = new self( $params );
64 MediaWikiServices::getInstance()->getJobQueueGroup()->push( $job );
65 }
66
67 return true;
68 }
69}
70
72class_alias( NullJob::class, 'NullJob' );
Describe and execute a background job.
Definition Job.php:27
array $params
Array of job parameters.
Definition Job.php:32
No-op job that does nothing.
Definition NullJob.php:40
run()
Run the job.If this method returns false or completes exceptionally, the job runner will retry execut...
Definition NullJob.php:56
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.
Interface for generic jobs only uses the parameters field and are JSON serializable.
if(count( $args)< 1) $job