MediaWiki  REL1_24
Job Class Reference

Class to both describe a background job and handle jobs. More...

Inheritance diagram for Job:
Collaboration diagram for Job:

List of all members.

Public Member Functions

 __construct ($command, $title, $params=false)
 allowRetries ()
 getDeduplicationInfo ()
 Subclasses may need to override this to make duplication detection work.
 getLastError ()
 getParams ()
 getReleaseTimestamp ()
 getRootJobParams ()
 getTitle ()
 getType ()
 hasRootJobParams ()
 ignoreDuplicates ()
 insert ()
 Insert a single job into the queue.
 run ()
 Run the job.
 toString ()
 workItemCount ()

Static Public Member Functions

static batchInsert ($jobs)
 Batch-insert a group of jobs into the queue.
static factory ($command, Title $title, $params=false)
 Create the appropriate object to handle a specific job.
static newRootJobParams ($key)
static pop ()
 Pop a job off the front of the queue.
static pop_type ($type)
 Pop a job of a certain type.
static safeBatchInsert ($jobs)
 Insert a group of jobs into the queue.

Public Attributes

string $command
 *
array $metadata = array()
 Additional queue metadata *.
array bool $params
 Array of job parameters or false if none *.

Protected Member Functions

 setLastError ($error)

Protected Attributes

string $error
 Text for error that occurred last *.
bool $removeDuplicates
 Expensive jobs may set this to true *.
Title $title
 *

Detailed Description

Class to both describe a background job and handle jobs.

The queue aspects of this class are now deprecated. Using the class to push jobs onto queues is deprecated (use JobSpecification).

Definition at line 31 of file Job.php.


Constructor & Destructor Documentation

Job::__construct ( command,
title,
params = false 
)
Parameters:
string$command
Title$title
array | bool$params

Definition at line 142 of file Job.php.

References $command, $params, $title, command, and title.


Member Function Documentation

Returns:
bool Whether this job can be retried on failure by job runners
Since:
1.21

Reimplemented in PublishStashedFileJob, and AssembleUploadChunksJob.

Definition at line 193 of file Job.php.

static Job::batchInsert ( jobs) [static]

Batch-insert a group of jobs into the queue.

This will be wrapped in a transaction with a forced commit.

This may add duplicate at insert time, but they will be removed later on, when the first one is popped.

Parameters:
array$jobsArray of Job objects
Returns:
bool
Deprecated:
since 1.21

Definition at line 88 of file Job.php.

static Job::factory ( command,
Title title,
params = false 
) [static]

Create the appropriate object to handle a specific job.

Parameters:
string$commandJob command
Title$titleAssociated title
array | bool$paramsJob parameters
Exceptions:
MWException
Returns:
Job

Definition at line 67 of file Job.php.

Referenced by RefreshLinksJob\runForTitle().

Subclasses may need to override this to make duplication detection work.

The resulting map conveys everything that makes the job unique. This is only checked if ignoreDuplicates() returns true, meaning that duplicate jobs are supposed to be ignored.

Returns:
array Map of key/values
Since:
1.21

Implements IJobSpecification.

Reimplemented in RefreshLinksJob, PublishStashedFileJob, RefreshLinksJob2, and AssembleUploadChunksJob.

Definition at line 215 of file Job.php.

Definition at line 341 of file Job.php.

Returns:
array

Implements IJobSpecification.

Definition at line 168 of file Job.php.

Referenced by DuplicateJob\newFromJob(), and BacklinkJobUtils\partitionBacklinkJob().

Returns:
int|null UNIX timestamp to delay running this job until, otherwise null
Since:
1.22

Implements IJobSpecification.

Definition at line 176 of file Job.php.

Returns:
Title

Implements IJobSpecification.

Definition at line 161 of file Job.php.

Referenced by DuplicateJob\newFromJob(), and BacklinkJobUtils\partitionBacklinkJob().

Returns:
string

Implements IJobSpecification.

Definition at line 154 of file Job.php.

Referenced by DuplicateJob\newFromJob().

See also:
JobQueue::deduplicateRootJob()
Returns:
bool
Since:
1.22

Definition at line 269 of file Job.php.

Referenced by JobQueue\doDeduplicateRootJob().

Returns:
bool Whether only one of each identical set of jobs should be run

Implements IJobSpecification.

Definition at line 185 of file Job.php.

Insert a single job into the queue.

Returns:
bool True on success
Deprecated:
since 1.21

Definition at line 279 of file Job.php.

References JobQueueGroup\singleton().

static Job::newRootJobParams ( key) [static]
See also:
JobQueue::deduplicateRootJob()
Parameters:
string$keyA key that identifies the task
Returns:
array Map of:
  • rootJobSignature : hash (e.g. SHA1) that identifies the task
  • rootJobTimestamp : TS_MW timestamp of this instance of the task
Since:
1.21

Definition at line 241 of file Job.php.

Referenced by RefreshLinksPartitionTest\testRefreshLinks(), and JobQueueTest\testRootDeduplication().

static Job::pop ( ) [static]

Pop a job off the front of the queue.

This is subject to $wgJobTypesExcludedFromDefaultQueue.

Returns:
Job|bool False if there are no jobs
Deprecated:
since 1.21

Definition at line 129 of file Job.php.

static Job::pop_type ( type) [static]

Pop a job of a certain type.

This tries less hard than pop() to actually find a job; it may be adversely affected by concurrent job runners.

Parameters:
string$type
Returns:
Job|bool Returns false if there are no jobs
Deprecated:
since 1.21

Definition at line 118 of file Job.php.

static Job::safeBatchInsert ( jobs) [static]

Insert a group of jobs into the queue.

Same as batchInsert() but does not commit and can thus be rolled-back as part of a larger transaction. However, large batches of jobs can cause slave lag.

Parameters:
array$jobsArray of Job objects
Returns:
bool
Deprecated:
since 1.21

Definition at line 104 of file Job.php.

Job::setLastError ( error) [protected]
Returns:
string

Definition at line 287 of file Job.php.

Returns:
int Number of actually "work items" handled in this job
See also:
$wgJobBackoffThrottling
Since:
1.23

Reimplemented in RefreshLinksJob, and HTMLCacheUpdateJob.

Definition at line 202 of file Job.php.


Member Data Documentation

string Job::$command

*

Definition at line 32 of file Job.php.

Referenced by __construct().

string Job::$error [protected]

Text for error that occurred last *.

Definition at line 42 of file Job.php.

array Job::$metadata = array()

Additional queue metadata *.

Definition at line 36 of file Job.php.

bool Job::$removeDuplicates [protected]

Expensive jobs may set this to true *.

Definition at line 40 of file Job.php.


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