MediaWiki REL1_32
|
Class to both describe a background job and handle jobs. More...
Public Member Functions | |
__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. | |
isRootJob () | |
run () | |
Run the job. | |
teardown ( $status) | |
Do any final cleanup after run(), deferred updates, and all DB commits happen. | |
toString () | |
workItemCount () | |
Static Public Member Functions | |
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 | |
string | $command |
array | $metadata = [] |
Additional queue metadata. | |
array | $params |
Array of job parameters. | |
Protected Member Functions | |
addTeardownCallback ( $callback) | |
setLastError ( $error) | |
Protected Attributes | |
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 |
Class to both describe a background job and handle jobs.
To push jobs onto queues, use JobQueueGroup::singleton()->push();
Job::__construct | ( | $command, | |
$title, | |||
$params = false |
|||
) |
|
protected |
callable | $callback | A function with one parameter, the success status, which will be false if the job failed or it succeeded but the DB changes could not be committed or any deferred updates threw an exception. (This parameter was added in 1.28.) |
Definition at line 310 of file Job.php.
Referenced by AssembleUploadChunksJob\run(), and PublishStashedFileJob\run().
Job::allowRetries | ( | ) |
Reimplemented in AssembleUploadChunksJob, PublishStashedFileJob, and ThumbnailRenderJob.
|
static |
Create the appropriate object to handle a specific job.
MWException |
Definition at line 73 of file Job.php.
References $command, $handler, $job, $params, $title, and $wgJobClasses.
Referenced by JobQueueDB\doPop(), JobQueueRedis\getJobFromFields(), JobQueueRedis\getJobFromUidInternal(), JobQueueDB\getJobIterator(), JobQueueMemory\jobFromSpecInternal(), and JobTest\testJobFactory().
Job::getDeduplicationInfo | ( | ) |
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.
Implements IJobSpecification.
Reimplemented in AssembleUploadChunksJob, CategoryMembershipChangeJob, ClearUserWatchlistJob, HTMLCacheUpdateJob, PublishStashedFileJob, and RefreshLinksJob.
Definition at line 225 of file Job.php.
References getParams(), getTitle(), and getType().
Job::getParams | ( | ) |
Implements IJobSpecification.
Definition at line 142 of file Job.php.
References $params.
Referenced by getDeduplicationInfo(), and ClearUserWatchlistJob\run().
Job::getQueuedTimestamp | ( | ) |
Definition at line 160 of file Job.php.
References wfTimestampOrNull().
Referenced by getReadyTimestamp().
Job::getReadyTimestamp | ( | ) |
Definition at line 180 of file Job.php.
References getQueuedTimestamp(), and getReleaseTimestamp().
Job::getReleaseTimestamp | ( | ) |
Implements IJobSpecification.
Definition at line 150 of file Job.php.
References wfTimestampOrNull().
Referenced by getReadyTimestamp().
Job::getRequestId | ( | ) |
Definition at line 172 of file Job.php.
Referenced by DeletePageJob\run().
Job::getRootJobParams | ( | ) |
Implements IJobSpecification.
Definition at line 279 of file Job.php.
Referenced by HTMLCacheUpdateJob\run(), and RefreshLinksJob\run().
Job::getTitle | ( | ) |
Implements IJobSpecification.
Definition at line 135 of file Job.php.
References $title.
Referenced by getDeduplicationInfo(), and ClearUserWatchlistJob\run().
Job::getType | ( | ) |
Implements IJobSpecification.
Definition at line 128 of file Job.php.
References $command.
Referenced by JobQueue\ack(), JobQueueGroup\ack(), JobQueueGroup\deduplicateRootJob(), and getDeduplicationInfo().
Job::hasExecutionFlag | ( | $flag | ) |
Job::hasRootJobParams | ( | ) |
Implements IJobSpecification.
Definition at line 291 of file Job.php.
Referenced by isRootJob().
Job::ignoreDuplicates | ( | ) |
Whether the queue should reject insertion of this job if a duplicate exists.
This can be used to avoid duplicated effort or combined with delayed jobs to coalesce updates into larger batches. Claimed jobs are never treated as duplicates of new jobs, and some queues may allow a few duplicates due to network partitions and fail-over. Thus, additional locking is needed to enforce mutual exclusion if this is really needed.
Implements IJobSpecification.
Definition at line 195 of file Job.php.
References $removeDuplicates.
Job::isRootJob | ( | ) |
Implements IJobSpecification.
Definition at line 300 of file Job.php.
References hasRootJobParams().
|
static |
Get "root job" parameters for a task.
This is used to no-op redundant jobs, including child jobs of jobs, as long as the children inherit the root job parameters. When a job with root job parameters and "rootJobIsSelf" set is pushed, the deduplicateRootJob() method is automatically called on it. If the root job is only virtual and not actually pushed (e.g. the sub-jobs are inserted directly), then call deduplicateRootJob() directly.
string | $key | A key that identifies the task |
Definition at line 266 of file Job.php.
References wfTimestampNow().
Referenced by HTMLCacheUpdateJob\newForBacklinks(), LinksUpdate\queueRecursiveJobsForTable(), RefreshLinksPartitionTest\testRefreshLinks(), and JobQueueTest\testRootDeduplication().
|
abstract |
Run the job.
Reimplemented in ActivityUpdateJob, AssembleUploadChunksJob, CategoryMembershipChangeJob, CdnPurgeJob, ClearUserWatchlistJob, ClearWatchlistNotificationsJob, DeleteLinksJob, DeletePageJob, DoubleRedirectJob, DuplicateJob, EmaillingJob, EnotifNotifyJob, EnqueueJob, HTMLCacheUpdateJob, NullJob, PublishStashedFileJob, RecentChangesUpdateJob, RefreshLinksJob, ThumbnailRenderJob, and UserGroupExpiryJob.
|
protected |
Definition at line 384 of file Job.php.
Referenced by ThumbnailRenderJob\hitThumbUrl(), AssembleUploadChunksJob\run(), CategoryMembershipChangeJob\run(), ClearUserWatchlistJob\run(), DeleteLinksJob\run(), DoubleRedirectJob\run(), PublishStashedFileJob\run(), ThumbnailRenderJob\run(), and RefreshLinksJob\runForTitle().
Job::teardown | ( | $status | ) |
Job::toString | ( | ) |
Job::workItemCount | ( | ) |
Reimplemented in HTMLCacheUpdateJob, and RefreshLinksJob.
string Job::$command |
Definition at line 32 of file Job.php.
Referenced by __construct(), factory(), getType(), and toString().
|
protected |
Text for error that occurred last.
Definition at line 47 of file Job.php.
Referenced by getLastError(), and setLastError().
|
protected |
array Job::$params |
Array of job parameters.
Definition at line 35 of file Job.php.
Referenced by __construct(), UserGroupExpiryJob\__construct(), DeletePageJob\__construct(), ActivityUpdateJob\__construct(), AssembleUploadChunksJob\__construct(), CdnPurgeJob\__construct(), ClearWatchlistNotificationsJob\__construct(), DeleteLinksJob\__construct(), DoubleRedirectJob\__construct(), DuplicateJob\__construct(), EnotifNotifyJob\__construct(), EnqueueJob\__construct(), HTMLCacheUpdateJob\__construct(), NullJob\__construct(), PublishStashedFileJob\__construct(), RefreshLinksJob\__construct(), ThumbnailRenderJob\__construct(), ClearUserWatchlistJob\__construct(), EmaillingJob\__construct(), factory(), getParams(), RefreshLinksJob\newDynamic(), HTMLCacheUpdateJob\newForBacklinks(), RefreshLinksJob\newPrioritized(), and NullJob\run().
|
protected |
Expensive jobs may set this to true.
Definition at line 44 of file Job.php.
Referenced by ignoreDuplicates().
|
protected |
Definition at line 41 of file Job.php.
Referenced by __construct(), DeletePageJob\__construct(), ActivityUpdateJob\__construct(), AssembleUploadChunksJob\__construct(), CdnPurgeJob\__construct(), ClearWatchlistNotificationsJob\__construct(), DeleteLinksJob\__construct(), DoubleRedirectJob\__construct(), DuplicateJob\__construct(), EnotifNotifyJob\__construct(), EnqueueJob\__construct(), HTMLCacheUpdateJob\__construct(), NullJob\__construct(), PublishStashedFileJob\__construct(), RefreshLinksJob\__construct(), ThumbnailRenderJob\__construct(), factory(), DoubleRedirectJob\fixRedirects(), DoubleRedirectJob\getFinalDestination(), getTitle(), HTMLCacheUpdateJob\invalidateTitles(), RefreshLinksJob\newDynamic(), HTMLCacheUpdateJob\newForBacklinks(), RefreshLinksJob\newPrioritized(), CategoryMembershipChangeJob\notifyUpdatesForRevision(), HTMLCacheUpdateJob\run(), NullJob\run(), and RefreshLinksJob\runForTitle().