MediaWiki
master
|
Class to both describe a background job and handle jobs. More...
Public Member Functions | ||||
__construct ( $command, $params=null) | ||||
Stable to call. More... | ||||
allowRetries () | ||||
| ||||
getDeduplicationInfo () | ||||
Subclasses may need to override this to make duplication detection work. More... | ||||
getLastError () | ||||
| ||||
getMetadata ( $field=null) | ||||
Stable to override. More... | ||||
getParams () | ||||
| ||||
getQueuedTimestamp () | ||||
getReadyTimestamp () | ||||
| ||||
getReleaseTimestamp () | ||||
Stable to override. More... | ||||
getRequestId () | ||||
| ||||
getRootJobParams () | ||||
Stable to override. More... | ||||
getTitle () | ||||
getType () | ||||
| ||||
hasExecutionFlag ( $flag) | ||||
| ||||
hasRootJobParams () | ||||
Stable to override. More... | ||||
ignoreDuplicates () | ||||
Whether the queue should reject insertion of this job if a duplicate exists. More... | ||||
isRootJob () | ||||
Stable to override. More... | ||||
setMetadata ( $field, $value) | ||||
Stable to override. More... | ||||
teardown ( $status) | ||||
Stable to override More... | ||||
toString () | ||||
| ||||
workItemCount () | ||||
Stable to override. More... | ||||
![]() | ||||
run () | ||||
Run the job. More... | ||||
tearDown ( $status) | ||||
Do any final cleanup after run(), deferred updates, and all DB commits happen. More... | ||||
Static Public Member Functions | |
static | factory ( $command, $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... | |
int | $executionFlags = 0 |
Bitfield of JOB_* class constants. More... | |
bool | $removeDuplicates = false |
Expensive jobs may set this to true. More... | |
callable[] | $teardownCallbacks = [] |
Title | $title |
Class to both describe a background job and handle jobs.
To push jobs onto queues, use JobQueueGroup::singleton()->push();
Job objects are constructed by the job queue, and must have an approriate constructor signature; see IJobSpecification.
Stable to extend
Job::__construct | ( | $command, | |
$params = null |
|||
) |
Stable to call.
string | $command | |
array | Title | null | $params |
Definition at line 123 of file Job.php.
References $command, $params, $title, Title\getDBkey(), Title\getNamespace(), WebRequest\getRequestId(), Title\makeTitle(), 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.) |
Definition at line 390 of file Job.php.
Referenced by AssembleUploadChunksJob\run(), and PublishStashedFileJob\run().
Job::allowRetries | ( | ) |
Implements RunnableJob.
Reimplemented in ThumbnailRenderJob, PublishStashedFileJob, and AssembleUploadChunksJob.
|
static |
Create the appropriate object to handle a specific job.
InvalidArgumentException |
Definition at line 68 of file Job.php.
References $command, $job, $params, $title, $wgJobClasses, Title\makeTitle(), and NS_SPECIAL.
Referenced by JobQueue\factoryJob().
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.
Stable to override
Implements IJobSpecification.
Reimplemented in RefreshLinksJob, PublishStashedFileJob, HTMLCacheUpdateJob, ClearUserWatchlistJob, CategoryMembershipChangeJob, and AssembleUploadChunksJob.
Definition at line 304 of file Job.php.
References getParams(), and getType().
Job::getLastError | ( | ) |
Implements RunnableJob.
Definition at line 472 of file Job.php.
References $error.
Job::getMetadata | ( | $field = null | ) |
Stable to override.
string | null | $field | Metadata field or null to get all the metadata |
Implements RunnableJob.
Definition at line 198 of file Job.php.
References $metadata.
Referenced by setMetadata().
Job::getParams | ( | ) |
Implements IJobSpecification.
Definition at line 188 of file Job.php.
References $params.
Referenced by getDeduplicationInfo(), and ClearUserWatchlistJob\run().
Job::getQueuedTimestamp | ( | ) |
Definition at line 239 of file Job.php.
References wfTimestampOrNull().
Referenced by getReadyTimestamp().
Job::getReadyTimestamp | ( | ) |
Implements RunnableJob.
Definition at line 257 of file Job.php.
References getQueuedTimestamp(), and getReleaseTimestamp().
Job::getReleaseTimestamp | ( | ) |
Stable to override.
Implements IJobSpecification.
Definition at line 229 of file Job.php.
References wfTimestampOrNull().
Referenced by getReadyTimestamp().
Job::getRequestId | ( | ) |
Implements RunnableJob.
Definition at line 249 of file Job.php.
Referenced by DeletePageJob\run().
Job::getRootJobParams | ( | ) |
Stable to override.
Implements IJobSpecification.
Definition at line 357 of file Job.php.
Referenced by HTMLCacheUpdateJob\run(), and RefreshLinksJob\run().
Job::getType | ( | ) |
Implements IJobSpecification.
Definition at line 173 of file Job.php.
References $command.
Referenced by getDeduplicationInfo().
Job::hasExecutionFlag | ( | $flag | ) |
int | $flag | JOB_* class constant |
Implements RunnableJob.
Job::hasRootJobParams | ( | ) |
Stable to override.
Implements IJobSpecification.
Definition at line 370 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.
Stable to override
Implements IJobSpecification.
Definition at line 274 of file Job.php.
References $removeDuplicates.
Job::isRootJob | ( | ) |
Stable to override.
Implements IJobSpecification.
Definition at line 380 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 343 of file Job.php.
References wfTimestampNow().
Referenced by HTMLCacheUpdateJob\newForBacklinks(), and LinksUpdate\queueRecursiveJobsForTable().
|
protected |
Definition at line 464 of file Job.php.
References $error.
Referenced by RefreshLinksJob\getCurrentRevisionIfUnchanged(), ThumbnailRenderJob\hitThumbUrl(), AssembleUploadChunksJob\run(), CategoryMembershipChangeJob\run(), ClearUserWatchlistJob\run(), DeleteLinksJob\run(), DoubleRedirectJob\run(), PublishStashedFileJob\run(), RefreshLinksJob\run(), ThumbnailRenderJob\run(), and RefreshLinksJob\runForTitle().
Job::setMetadata | ( | $field, | |
$value | |||
) |
Stable to override.
string | $field | Key name to set the value for |
mixed | $value | The value to set the field for |
Implements RunnableJob.
Definition at line 213 of file Job.php.
References getMetadata().
Job::toString | ( | ) |
Implements RunnableJob.
Definition at line 408 of file Job.php.
References $command, $s, and FormatJson\encode().
Job::workItemCount | ( | ) |
Stable to override.
Implements RunnableJob.
Reimplemented in RefreshLinksJob, and HTMLCacheUpdateJob.
string Job::$command |
Definition at line 37 of file Job.php.
Referenced by __construct(), WatchlistExpiryJob\__construct(), factory(), getType(), and toString().
|
protected |
Text for error that occurred last.
Definition at line 52 of file Job.php.
Referenced by getLastError(), and setLastError().
|
protected |
array Job::$metadata = [] |
array Job::$params |
Array of job parameters.
Definition at line 40 of file Job.php.
Referenced by __construct(), EmaillingJob\__construct(), CdnPurgeJob\__construct(), ClearUserWatchlistJob\__construct(), ClearWatchlistNotificationsJob\__construct(), DeletePageJob\__construct(), DuplicateJob\__construct(), EnqueueJob\__construct(), NullJob\__construct(), RevertedTagUpdateJob\__construct(), UserEditCountInitJob\__construct(), UserGroupExpiryJob\__construct(), UserOptionsUpdateJob\__construct(), ActivityUpdateJob\__construct(), WatchlistExpiryJob\__construct(), AssembleUploadChunksJob\__construct(), CategoryMembershipChangeJob\__construct(), DeleteLinksJob\__construct(), DoubleRedirectJob\__construct(), EnotifNotifyJob\__construct(), HTMLCacheUpdateJob\__construct(), PublishStashedFileJob\__construct(), RecentChangesUpdateJob\__construct(), RefreshLinksJob\__construct(), ThumbnailRenderJob\__construct(), factory(), getParams(), RefreshLinksJob\newDynamic(), HTMLCacheUpdateJob\newForBacklinks(), RefreshLinksJob\newPrioritized(), and NullJob\run().
|
protected |
Expensive jobs may set this to true.
Definition at line 49 of file Job.php.
Referenced by ignoreDuplicates().
|
protected |
Definition at line 46 of file Job.php.
Referenced by __construct(), ActivityUpdateJob\__construct(), AssembleUploadChunksJob\__construct(), CategoryMembershipChangeJob\__construct(), DeleteLinksJob\__construct(), DoubleRedirectJob\__construct(), EnotifNotifyJob\__construct(), HTMLCacheUpdateJob\__construct(), PublishStashedFileJob\__construct(), RecentChangesUpdateJob\__construct(), RefreshLinksJob\__construct(), ThumbnailRenderJob\__construct(), factory(), DoubleRedirectJob\fixRedirects(), RefreshLinksJob\getCurrentRevisionIfUnchanged(), DoubleRedirectJob\getFinalDestination(), getTitle(), RefreshLinksJob\newDynamic(), HTMLCacheUpdateJob\newForBacklinks(), RefreshLinksJob\newPrioritized(), CategoryMembershipChangeJob\newSpec(), CategoryMembershipChangeJob\notifyUpdatesForRevision(), HTMLCacheUpdateJob\run(), RefreshLinksJob\run(), and RefreshLinksJob\runForTitle().