MediaWiki  REL1_20
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, $id=0)
 getLastError ()
 insert ()
 Insert a single job into the queue.
 removeDuplicates ()
 Remove jobs in the job queue which are duplicates of this job.
 run ()
 Run the job.
 toString ()

Static Public Member Functions

static batchInsert ($jobs)
 Batch-insert a group of jobs into the queue.
static defaultQueueConditions ()
 SQL conditions to apply on most JobQueue queries.
static extractBlob ($blob)
static factory ($command, Title $title, $params=false, $id=0)
 Create the appropriate object to handle a specific job.
static makeBlob ($params)
static pop ($offset=0)
 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

 $command
 $error
 $id
 $params
 $removeDuplicates
Title $title

Protected Member Functions

 insertFields ()
 setLastError ($error)

Detailed Description

Class to both describe a background job and handle jobs.

Definition at line 29 of file Job.php.


Constructor & Destructor Documentation

Job::__construct ( command,
title,
params = false,
id = 0 
)
Parameters:
$command
$title
$paramsarray|bool
$idint

Definition at line 347 of file Job.php.


Member Function Documentation

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:
$jobsarray of Job objects

Definition at line 260 of file Job.php.

Referenced by DoubleRedirectJob\fixRedirects(), FixDoubleRedirects\queueJobs(), LinksUpdate\queueRecursiveJobs(), and RefreshLinksJob2\run().

static Job::defaultQueueConditions ( ) [static]

SQL conditions to apply on most JobQueue queries.

Whenever we exclude jobs types from the default queue, we want to make sure that queries to the job queue actually ignore them.

Returns:
array SQL conditions suitable for Database:: methods

Definition at line 325 of file Job.php.

Referenced by nextJobDB\checkJob(), and RunJobs\execute().

static Job::extractBlob ( blob) [static]
Parameters:
$blob
Returns:
bool|mixed

Definition at line 243 of file Job.php.

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

Create the appropriate object to handle a specific job.

Parameters:
$commandString: Job command
$titleTitle: Associated title
$paramsArray|bool: Job parameters
$idInt: Job identifier
Exceptions:
MWException
Returns:
Job

Definition at line 218 of file Job.php.

Referenced by DoubleRedirectJob\run().

Definition at line 443 of file Job.php.

Insert a single job into the queue.

Returns:
bool true on success

Definition at line 362 of file Job.php.

Job::insertFields ( ) [protected]
Returns:
array

Definition at line 380 of file Job.php.

static Job::makeBlob ( params) [static]
Parameters:
$params
Returns:
string

Definition at line 231 of file Job.php.

static Job::pop ( offset = 0) [static]

Pop a job off the front of the queue.

Parameters:
$offsetInteger: Number of jobs to skip
Returns:
Job or false if there's no jobs

Definition at line 114 of file Job.php.

Referenced by UploadFromUrlTest\doAsyncUpload(), RunJobs\execute(), UploadFromUrlTest\testClearQueue(), UploadFromUrlTest\testLeaveMessage(), UploadFromUrlTest\testSetupUrlDownload(), and UploadFromUrlTest\testSyncDownload().

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:
$typestring
Returns:
Job

Definition at line 64 of file Job.php.

Referenced by RunJobs\execute().

Remove jobs in the job queue which are duplicates of this job.

This is deadlock-prone and so starts its own transaction.

Definition at line 396 of file Job.php.

Job::run ( ) [abstract]

Run the job.

Returns:
boolean success

Reimplemented in HTMLCacheUpdateJob, RefreshLinksJob2, DoubleRedirectJob, UploadFromUrlJob, RefreshLinksJob, EmaillingJob, and EnotifNotifyJob.

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:
$jobsarray of Job objects

Definition at line 297 of file Job.php.

Job::setLastError ( error) [protected]

Definition at line 439 of file Job.php.

References $error.

Referenced by DoubleRedirectJob\run().

Returns:
string

Definition at line 417 of file Job.php.


Member Data Documentation

Job::$command

Definition at line 35 of file Job.php.

Job::$error

Definition at line 35 of file Job.php.

Referenced by setLastError().

Definition at line 35 of file Job.php.


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