MediaWiki
1.30.2
|
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. More... | |
getLastError () | |
getParams () | |
getQueuedTimestamp () | |
getReadyTimestamp () | |
getReleaseTimestamp () | |
getRequestId () | |
getRootJobParams () | |
getTitle () | |
getType () | |
hasRootJobParams () | |
ignoreDuplicates () | |
Whether the queue should reject insertion of this job if a duplicate exists. More... | |
insert () | |
Insert a single job into the queue. More... | |
isRootJob () | |
run () | |
Run the job. More... | |
teardown ( $status) | |
Do any final cleanup after run(), deferred updates, and all DB commits happen. More... | |
toString () | |
workItemCount () | |
Static Public Member Functions | |
static | batchInsert ( $jobs) |
Batch-insert a group of jobs into the queue. More... | |
static | factory ( $command, Title $title, $params=[]) |
Create the appropriate object to handle a specific job. More... | |
static | newRootJobParams ( $key) |
Get "root job" parameters for a task. More... | |
Public Attributes | |
string | $command |
array | $metadata = [] |
Additional queue metadata. More... | |
array | $params |
Array of job parameters. More... | |
Protected Member Functions | |
addTeardownCallback ( $callback) | |
setLastError ( $error) | |
Protected Attributes | |
string | $error |
Text for error that occurred last. More... | |
bool | $removeDuplicates |
Expensive jobs may set this to true. More... | |
callable[] | $teardownCallbacks = [] |
Title | $title |
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).
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 319 of file Job.php.
Referenced by AssembleUploadChunksJob\run(), and PublishStashedFileJob\run().
Job::allowRetries | ( | ) |
Reimplemented in PublishStashedFileJob, and AssembleUploadChunksJob.
|
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.
Definition at line 122 of file Job.php.
References JobQueueGroup\singleton(), and wfDeprecated().
|
static |
Create the appropriate object to handle a specific job.
MWException |
Definition at line 68 of file Job.php.
References $command, $handler, $job, $params, $title, $wgJobClasses, and global.
Referenced by JobQueueDB\doPop(), JobQueueRedis\getJobFromFields(), JobQueueRedis\getJobFromUidInternal(), JobQueueDB\getJobIterator(), JobQueueMemory\jobFromSpecInternal(), RenameuserSQL\rename(), 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 RefreshLinksJob, CategoryMembershipChangeJob, PublishStashedFileJob, and AssembleUploadChunksJob.
Definition at line 230 of file Job.php.
References getParams(), getTitle(), and getType().
Job::getParams | ( | ) |
Implements IJobSpecification.
Definition at line 145 of file Job.php.
References $params.
Referenced by getDeduplicationInfo().
Job::getQueuedTimestamp | ( | ) |
Definition at line 163 of file Job.php.
References wfTimestampOrNull().
Referenced by getReadyTimestamp().
Job::getReadyTimestamp | ( | ) |
Definition at line 185 of file Job.php.
References getQueuedTimestamp(), and getReleaseTimestamp().
Job::getReleaseTimestamp | ( | ) |
Implements IJobSpecification.
Definition at line 153 of file Job.php.
References wfTimestampOrNull().
Referenced by getReadyTimestamp().
Job::getRequestId | ( | ) |
Job::getRootJobParams | ( | ) |
Implements IJobSpecification.
Definition at line 284 of file Job.php.
Referenced by HTMLCacheUpdateJob\run(), and RefreshLinksJob\run().
Job::getTitle | ( | ) |
Implements IJobSpecification.
Definition at line 138 of file Job.php.
References $title.
Referenced by getDeduplicationInfo().
Job::getType | ( | ) |
Implements IJobSpecification.
Definition at line 131 of file Job.php.
References $command.
Referenced by JobQueueGroup\ack(), JobQueue\ack(), JobQueueGroup\deduplicateRootJob(), and getDeduplicationInfo().
Job::hasRootJobParams | ( | ) |
Implements IJobSpecification.
Definition at line 300 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 200 of file Job.php.
References $removeDuplicates.
Job::insert | ( | ) |
Insert a single job into the queue.
Definition at line 339 of file Job.php.
References JobQueueGroup\singleton().
Job::isRootJob | ( | ) |
Implements IJobSpecification.
Definition at line 309 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 271 of file Job.php.
References wfTimestampNow().
Referenced by HTMLCacheUpdateJob\newForBacklinks(), LinksUpdate\queueRecursiveJobsForTable(), RefreshLinksPartitionTest\testRefreshLinks(), and JobQueueTest\testRootDeduplication().
|
abstract |
Run the job.
Reimplemented in DoubleRedirectJob, EnqueueJob, RefreshLinksJob, HTMLCacheUpdateJob, NullJob, RecentChangesUpdateJob, DuplicateJob, CategoryMembershipChangeJob, CdnPurgeJob, ActivityUpdateJob, DeleteLinksJob, PublishStashedFileJob, AssembleUploadChunksJob, EmaillingJob, EnotifNotifyJob, ThumbnailRenderJob, RenameUserJob, and CreatePdfThumbnailsJob.
|
protected |
Definition at line 403 of file Job.php.
Referenced by ThumbnailRenderJob\run(), AssembleUploadChunksJob\run(), PublishStashedFileJob\run(), DeleteLinksJob\run(), CategoryMembershipChangeJob\run(), DoubleRedirectJob\run(), and RefreshLinksJob\runForTitle().
Job::teardown | ( | $status | ) |
Job::toString | ( | ) |
Definition at line 347 of file Job.php.
References $command, $s, $value, as, captcha-old\count, FormatJson\encode(), string, and title.
Job::workItemCount | ( | ) |
Reimplemented in RefreshLinksJob, and HTMLCacheUpdateJob.
string Job::$command |
Definition at line 33 of file Job.php.
Referenced by __construct(), factory(), getType(), and toString().
|
protected |
Text for error that occurred last.
Definition at line 48 of file Job.php.
Referenced by getLastError(), and setLastError().
array Job::$metadata = [] |
Additional queue metadata.
Definition at line 39 of file Job.php.
Referenced by CreatePdfThumbnailsJob\insertJobs().
array Job::$params |
Array of job parameters.
Definition at line 36 of file Job.php.
Referenced by CreatePdfThumbnailsJob\__construct(), RenameUserJob\__construct(), ActivityUpdateJob\__construct(), ThumbnailRenderJob\__construct(), EnotifNotifyJob\__construct(), RecentChangesUpdateJob\__construct(), EmaillingJob\__construct(), AssembleUploadChunksJob\__construct(), PublishStashedFileJob\__construct(), DeleteLinksJob\__construct(), CdnPurgeJob\__construct(), DuplicateJob\__construct(), HTMLCacheUpdateJob\__construct(), CategoryMembershipChangeJob\__construct(), EnqueueJob\__construct(), RefreshLinksJob\__construct(), DoubleRedirectJob\__construct(), NullJob\__construct(), __construct(), factory(), getParams(), RefreshLinksJob\newDynamic(), RefreshLinksJob\newPrioritized(), and NullJob\run().
|
protected |
Expensive jobs may set this to true.
Definition at line 45 of file Job.php.
Referenced by ignoreDuplicates().
|
protected |
Definition at line 42 of file Job.php.
Referenced by CreatePdfThumbnailsJob\__construct(), RenameUserJob\__construct(), ActivityUpdateJob\__construct(), EnotifNotifyJob\__construct(), ThumbnailRenderJob\__construct(), AssembleUploadChunksJob\__construct(), RecentChangesUpdateJob\__construct(), PublishStashedFileJob\__construct(), DeleteLinksJob\__construct(), CdnPurgeJob\__construct(), DuplicateJob\__construct(), HTMLCacheUpdateJob\__construct(), CategoryMembershipChangeJob\__construct(), EnqueueJob\__construct(), DoubleRedirectJob\__construct(), RefreshLinksJob\__construct(), NullJob\__construct(), __construct(), factory(), DoubleRedirectJob\fixRedirects(), CategoryMembershipChangeJob\getCategoriesAtRev(), DoubleRedirectJob\getFinalDestination(), getTitle(), CreatePdfThumbnailsJob\insertJobs(), HTMLCacheUpdateJob\invalidateTitles(), RefreshLinksJob\newDynamic(), HTMLCacheUpdateJob\newForBacklinks(), RefreshLinksJob\newPrioritized(), CategoryMembershipChangeJob\notifyUpdatesForRevision(), NullJob\run(), HTMLCacheUpdateJob\run(), and RefreshLinksJob\runForTitle().