MediaWiki 1.42.0
|
Describe and execute a background job. More...
Inherits RunnableJob.
Inherited by ActivityUpdateJob, AssembleUploadChunksJob, CategoryMembershipChangeJob, CdnPurgeJob, ClearUserWatchlistJob, ClearWatchlistNotificationsJob, DeleteLinksJob, DeletePageJob, DoubleRedirectJob, DuplicateJob, EmaillingJob, EnotifNotifyJob, HTMLCacheUpdateJob, NullJob, ParsoidCachePrewarmJob, PublishStashedFileJob, RecentChangesUpdateJob, RefreshLinksJob, RenameUserJob, RevertedTagUpdateJob, ThumbnailRenderJob, UploadFromUrlJob, UserEditCountInitJob, UserGroupExpiryJob, UserOptionsUpdateJob, and WatchlistExpiryJob.
Public Member Functions | ||||
__construct ( $command, $params=null) | ||||
allowRetries () | ||||
| ||||
getDeduplicationInfo () | ||||
Subclasses may need to override this to make duplication detection work. | ||||
getLastError () | ||||
| ||||
getMetadata ( $field=null) | ||||
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 () | ||||
setMetadata ( $field, $value) | ||||
teardown ( $status) | ||||
toString () | ||||
| ||||
workItemCount () | ||||
Public Member Functions inherited from RunnableJob | ||||
run () | ||||
Run the job. | ||||
tearDown ( $status) | ||||
Do any final cleanup after run(), deferred updates, and all DB commits happen. | ||||
Static Public Member Functions | |
static | factory ( $command, $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 = false |
Expensive jobs may set this to true. | |
callable[] | $teardownCallbacks = [] |
Title | $title |
Describe and execute a background job.
Push jobs onto queues via the JobQueueGroup service.
Job objects must implement IJobSpecification to allow JobQueue to store the job, and later re-constructing the object from storage in a JobRunner.
See the architecture doc for more information.
Job::__construct | ( | $command, | |
$params = null ) |
string | $command | |
array | PageReference | null | $params |
Definition at line 89 of file Job.php.
References $params, and NS_SPECIAL.
|
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.) |
Job::allowRetries | ( | ) |
Implements RunnableJob.
Reimplemented in AssembleUploadChunksJob, and ThumbnailRenderJob.
|
static |
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, RefreshLinksJob, and UploadFromUrlJob.
Definition at line 270 of file Job.php.
References getParams(), and getType().
Job::getLastError | ( | ) |
Job::getMetadata | ( | $field = null | ) |
string | null | $field | Metadata field or null to get all the metadata |
Implements RunnableJob.
Definition at line 166 of file Job.php.
Referenced by setMetadata().
Job::getParams | ( | ) |
Implements IJobSpecification.
Definition at line 156 of file Job.php.
References $params.
Referenced by getDeduplicationInfo(), and ClearUserWatchlistJob\run().
Job::getQueuedTimestamp | ( | ) |
Definition at line 206 of file Job.php.
References wfTimestampOrNull().
Referenced by getReadyTimestamp().
Job::getReadyTimestamp | ( | ) |
Implements RunnableJob.
Definition at line 223 of file Job.php.
References getQueuedTimestamp(), and getReleaseTimestamp().
Job::getReleaseTimestamp | ( | ) |
Implements IJobSpecification.
Definition at line 197 of file Job.php.
References wfTimestampOrNull().
Referenced by getReadyTimestamp().
Job::getRequestId | ( | ) |
Implements RunnableJob.
Definition at line 215 of file Job.php.
Referenced by DeletePageJob\run().
Job::getRootJobParams | ( | ) |
Implements IJobSpecification.
Definition at line 323 of file Job.php.
Referenced by HTMLCacheUpdateJob\run(), and RefreshLinksJob\run().
Job::getType | ( | ) |
Implements IJobSpecification.
Definition at line 141 of file Job.php.
Referenced by getDeduplicationInfo().
Job::hasExecutionFlag | ( | $flag | ) |
int | $flag | JOB_* class constant |
Implements RunnableJob.
Job::hasRootJobParams | ( | ) |
Implements IJobSpecification.
Definition at line 336 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.
Job::isRootJob | ( | ) |
Implements IJobSpecification.
Definition at line 346 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 309 of file Job.php.
References wfTimestampNow().
Referenced by HTMLCacheUpdateJob\newForBacklinks(), and MediaWiki\Deferred\LinksUpdate\LinksUpdate\queueRecursiveJobsForTable().
Job::setMetadata | ( | $field, | |
$value ) |
string | $field | Key name to set the value for |
mixed | $value | The value to set the field for |
Implements RunnableJob.
Definition at line 181 of file Job.php.
References getMetadata().
Job::toString | ( | ) |
Implements RunnableJob.
Job::workItemCount | ( | ) |
Implements RunnableJob.
Reimplemented in HTMLCacheUpdateJob, and RefreshLinksJob.
string Job::$command |
Definition at line 42 of file Job.php.
Referenced by WatchlistExpiryJob\__construct().
|
protected |
|
protected |
array Job::$params |
Array of job parameters.
Definition at line 45 of file Job.php.
Referenced by DuplicateJob\__construct().
|
protected |
|
protected |
Definition at line 51 of file Job.php.
Referenced by ActivityUpdateJob\__construct(), DoubleRedirectJob\fixRedirects(), DoubleRedirectJob\getFinalDestination(), HTMLCacheUpdateJob\newForBacklinks(), CategoryMembershipChangeJob\notifyUpdatesForRevision(), and RefreshLinksJob\run().