MediaWiki REL1_31
NullJob Class Reference

Degenerate job that does nothing, but can optionally replace itself in the queue and/or sleep for a brief time period. More...

Inheritance diagram for NullJob:
Collaboration diagram for NullJob:

Public Member Functions

 __construct (Title $title, array $params)
 
 run ()
 Run the job.
 
- Public Member Functions inherited from Job
 __construct ( $command, $title, $params=false)
 
 allowRetries ()
 
 getDeduplicationInfo ()
 Subclasses may need to override this to make duplication detection work.
 
 getLastError ()
 
 getParams ()
 
 getQueuedTimestamp ()
 
 getReadyTimestamp ()
 
 getReleaseTimestamp ()
 
 getRequestId ()
 
 getRootJobParams ()
 
 getTitle ()
 
 getType ()
 
 hasExecutionFlag ( $flag)
 
 hasRootJobParams ()
 
 ignoreDuplicates ()
 Whether the queue should reject insertion of this job if a duplicate exists.
 
 insert ()
 Insert a single job into the queue.
 
 isRootJob ()
 
 teardown ( $status)
 Do any final cleanup after run(), deferred updates, and all DB commits happen.
 
 toString ()
 
 workItemCount ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Job
static batchInsert ( $jobs)
 Batch-insert a group of jobs into the queue.
 
static factory ( $command, Title $title, $params=[])
 Create the appropriate object to handle a specific job.
 
static newRootJobParams ( $key)
 Get "root job" parameters for a task.
 
- Public Attributes inherited from Job
string $command
 
array $metadata = []
 Additional queue metadata.
 
array $params
 Array of job parameters.
 
- Protected Member Functions inherited from Job
 addTeardownCallback ( $callback)
 
 setLastError ( $error)
 
- Protected Attributes inherited from Job
string $error
 Text for error that occurred last.
 
int $executionFlags = 0
 Bitfield of JOB_* class constants.
 
bool $removeDuplicates
 Expensive jobs may set this to true.
 
callable[] $teardownCallbacks = []
 
Title $title
 

Detailed Description

Degenerate job that does nothing, but can optionally replace itself in the queue and/or sleep for a brief time period.

These can be used to represent "no-op" jobs or test lock contention and performance.

Example:
Inserting a null job in the configured job queue:
$ php maintenance/eval.php
> $job = new NullJob( Title::newMainPage(), [ 'lives' => 10 ] );
> $queue->push( $job );
static singleton( $domain=false)
Degenerate job that does nothing, but can optionally replace itself in the queue and/or sleep for a b...
Definition NullJob.php:47
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
if(count( $args)< 1) $job
You can then confirm the job has been enqueued by using the showJobs.php maintenance utility:
$ php maintenance/showJobs.php --group
null: 1 queue; 0 claimed (0 active, 0 abandoned)
$

Definition at line 47 of file NullJob.php.

Constructor & Destructor Documentation

◆ __construct()

NullJob::__construct ( Title  $title,
array  $params 
)
Parameters
Title$title
array$paramsJob parameters (lives, usleep)

Definition at line 52 of file NullJob.php.

References Job\$params, and Job\$title.

Member Function Documentation

◆ run()

NullJob::run ( )

Run the job.

Returns
bool Success

Reimplemented from Job.

Definition at line 63 of file NullJob.php.

References $job, Job\$params, Job\$title, and JobQueueGroup\singleton().


The documentation for this class was generated from the following file: