MediaWiki master
NullJob.php
Go to the documentation of this file.
1<?php
22
26
54class NullJob extends Job implements GenericParameterJob {
58 public function __construct( array $params ) {
59 parent::__construct( 'null', $params );
60 if ( !isset( $this->params['lives'] ) ) {
61 $this->params['lives'] = 1;
62 }
63 if ( !isset( $this->params['usleep'] ) ) {
64 $this->params['usleep'] = 0;
65 }
66 $this->removeDuplicates = !empty( $this->params['removeDuplicates'] );
67 }
68
69 public function run() {
70 if ( $this->params['usleep'] > 0 ) {
71 usleep( $this->params['usleep'] );
72 }
73 if ( $this->params['lives'] > 1 ) {
75 $params['lives']--;
76 $job = new self( $params );
77 MediaWikiServices::getInstance()->getJobQueueGroup()->push( $job );
78 }
79
80 return true;
81 }
82}
83
85class_alias( NullJob::class, 'NullJob' );
Describe and execute a background job.
Definition Job.php:41
array $params
Array of job parameters.
Definition Job.php:46
No-op job that does nothing.
Definition NullJob.php:54
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