|
MediaWiki master
|
Describe and execute a background job. More...
Inherits MediaWiki\JobQueue\RunnableJob.
Inherited by MediaWiki\JobQueue\Jobs\AssembleUploadChunksJob, MediaWiki\JobQueue\Jobs\CategoryCountUpdateJob, MediaWiki\JobQueue\Jobs\CategoryMembershipChangeJob, MediaWiki\JobQueue\Jobs\CdnPurgeJob, MediaWiki\JobQueue\Jobs\DoubleRedirectJob, MediaWiki\JobQueue\Jobs\DuplicateJob, MediaWiki\JobQueue\Jobs\HTMLCacheUpdateJob, MediaWiki\JobQueue\Jobs\NullJob, MediaWiki\JobQueue\Jobs\ParsoidCachePrewarmJob, MediaWiki\JobQueue\Jobs\PublishStashedFileJob, MediaWiki\JobQueue\Jobs\RefreshLinksJob, MediaWiki\JobQueue\Jobs\RevertedTagUpdateJob, MediaWiki\JobQueue\Jobs\ThumbnailRenderJob, MediaWiki\JobQueue\Jobs\UploadFromUrlJob, MediaWiki\Mail\EmaillingJob, MediaWiki\Page\DeleteLinksJob, MediaWiki\Page\DeletePageJob, MediaWiki\RecentChanges\RecentChangeNotifyJob, MediaWiki\RecentChanges\RecentChangesUpdateJob, MediaWiki\RenameUser\Job\RenameUserDerivedJob, MediaWiki\RenameUser\Job\RenameUserTableJob, MediaWiki\User\Options\UserOptionsUpdateJob, MediaWiki\User\UserEditCountInitJob, MediaWiki\User\UserGroupExpiryJob, MediaWiki\Watchlist\ActivityUpdateJob, MediaWiki\Watchlist\ClearUserWatchlistJob, MediaWiki\Watchlist\ClearWatchlistNotificationsJob, and MediaWiki\Watchlist\WatchlistExpiryJob.

Public Member Functions | ||||
| __construct ( $command, $params=null) | ||||
| allowRetries () | ||||
Whether to retry execution of this job if run() returned false or threw an exception.
| ||||
| 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 MediaWiki\JobQueue\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.
Callers should use JobQueueGroup to enqueue jobs for deferred execution.
See the architecture doc for more information.
| MediaWiki\JobQueue\Job::__construct | ( | $command, | |
| $params = null ) |
| string | $command | |
| array | PageReference | null | $params | The parameters for the job. Note that if providing, a 'requestId' key it should be a value from Telemetry::getRequestId. |
Definition at line 76 of file Job.php.
References MediaWiki\JobQueue\Job\$command, MediaWiki\JobQueue\Job\$params, MediaWiki\Deferred\LinksUpdate\CategoryLinksTable\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 343 of file Job.php.
Referenced by MediaWiki\JobQueue\Jobs\AssembleUploadChunksJob\run().
| MediaWiki\JobQueue\Job::allowRetries | ( | ) |
Whether to retry execution of this job if run() returned false or threw an exception.
Implements MediaWiki\JobQueue\RunnableJob.
Reimplemented in MediaWiki\JobQueue\Jobs\AssembleUploadChunksJob, and MediaWiki\JobQueue\Jobs\ThumbnailRenderJob.
|
static |
Create the appropriate object to handle a specific job.
| string | $command | Job command |
| array | PageReference | $params | Job parameters |
Definition at line 62 of file Job.php.
References MediaWiki\MediaWikiServices\getInstance().
Referenced by MediaWiki\Mail\UserMailer\sendInternal().
| MediaWiki\JobQueue\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 MediaWiki\JobQueue\IJobSpecification.
Reimplemented in MediaWiki\JobQueue\Jobs\AssembleUploadChunksJob, MediaWiki\JobQueue\Jobs\CategoryMembershipChangeJob, MediaWiki\JobQueue\Jobs\HTMLCacheUpdateJob, MediaWiki\JobQueue\Jobs\PublishStashedFileJob, MediaWiki\JobQueue\Jobs\RefreshLinksJob, MediaWiki\JobQueue\Jobs\UploadFromUrlJob, and MediaWiki\Watchlist\ClearUserWatchlistJob.
Definition at line 257 of file Job.php.
References MediaWiki\JobQueue\Job\getParams(), and MediaWiki\JobQueue\Job\getType().
| MediaWiki\JobQueue\Job::getLastError | ( | ) |
Implements MediaWiki\JobQueue\RunnableJob.
Definition at line 432 of file Job.php.
References MediaWiki\JobQueue\Job\$error.
| MediaWiki\JobQueue\Job::getMetadata | ( | $field = null | ) |
| string | null | $field | Metadata field or null to get all the metadata |
Implements MediaWiki\JobQueue\RunnableJob.
Definition at line 153 of file Job.php.
References MediaWiki\JobQueue\Job\$metadata.
Referenced by MediaWiki\JobQueue\Job\setMetadata().
| MediaWiki\JobQueue\Job::getParams | ( | ) |
Implements MediaWiki\JobQueue\IJobSpecification.
Definition at line 143 of file Job.php.
References MediaWiki\JobQueue\Job\$params.
Referenced by MediaWiki\JobQueue\Job\getDeduplicationInfo(), and MediaWiki\Watchlist\ClearUserWatchlistJob\run().
| MediaWiki\JobQueue\Job::getQueuedTimestamp | ( | ) |
Definition at line 193 of file Job.php.
References wfTimestampOrNull().
Referenced by MediaWiki\JobQueue\Job\getReadyTimestamp().
| MediaWiki\JobQueue\Job::getReadyTimestamp | ( | ) |
Implements MediaWiki\JobQueue\RunnableJob.
Definition at line 210 of file Job.php.
References MediaWiki\JobQueue\Job\getQueuedTimestamp(), and MediaWiki\JobQueue\Job\getReleaseTimestamp().
| MediaWiki\JobQueue\Job::getReleaseTimestamp | ( | ) |
Implements MediaWiki\JobQueue\IJobSpecification.
Definition at line 184 of file Job.php.
References wfTimestampOrNull().
Referenced by MediaWiki\JobQueue\Job\getReadyTimestamp().
| MediaWiki\JobQueue\Job::getRequestId | ( | ) |
Implements MediaWiki\JobQueue\RunnableJob.
Definition at line 202 of file Job.php.
Referenced by MediaWiki\Page\DeletePageJob\run().
| MediaWiki\JobQueue\Job::getRootJobParams | ( | ) |
Implements MediaWiki\JobQueue\IJobSpecification.
Definition at line 310 of file Job.php.
Referenced by MediaWiki\JobQueue\Jobs\HTMLCacheUpdateJob\run(), and MediaWiki\JobQueue\Jobs\RefreshLinksJob\run().
|
final |
| MediaWiki\JobQueue\Job::getType | ( | ) |
Implements MediaWiki\JobQueue\IJobSpecification.
Definition at line 128 of file Job.php.
References MediaWiki\JobQueue\Job\$command.
Referenced by MediaWiki\JobQueue\Job\getDeduplicationInfo().
| MediaWiki\JobQueue\Job::hasExecutionFlag | ( | $flag | ) |
| int | $flag | JOB_* class constant |
Implements MediaWiki\JobQueue\RunnableJob.
| MediaWiki\JobQueue\Job::hasRootJobParams | ( | ) |
Implements MediaWiki\JobQueue\IJobSpecification.
Definition at line 323 of file Job.php.
Referenced by MediaWiki\JobQueue\Job\isRootJob().
| MediaWiki\JobQueue\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 MediaWiki\JobQueue\IJobSpecification.
Definition at line 227 of file Job.php.
References MediaWiki\JobQueue\Job\$removeDuplicates.
| MediaWiki\JobQueue\Job::isRootJob | ( | ) |
Implements MediaWiki\JobQueue\IJobSpecification.
Definition at line 333 of file Job.php.
References MediaWiki\JobQueue\Job\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 296 of file Job.php.
References wfTimestampNow().
Referenced by MediaWiki\JobQueue\Jobs\HTMLCacheUpdateJob\newForBacklinks(), and MediaWiki\Deferred\LinksUpdate\LinksUpdate\queueRecursiveJobsForTable().
|
protected |
| string | $error |
Definition at line 424 of file Job.php.
References MediaWiki\JobQueue\Job\$error.
Referenced by MediaWiki\JobQueue\Jobs\ThumbnailRenderJob\hitThumbUrl(), MediaWiki\JobQueue\Jobs\AssembleUploadChunksJob\run(), MediaWiki\JobQueue\Jobs\CategoryMembershipChangeJob\run(), MediaWiki\JobQueue\Jobs\DoubleRedirectJob\run(), MediaWiki\JobQueue\Jobs\RefreshLinksJob\run(), MediaWiki\JobQueue\Jobs\ThumbnailRenderJob\run(), MediaWiki\Page\DeleteLinksJob\run(), MediaWiki\RecentChanges\RecentChangeNotifyJob\run(), MediaWiki\Watchlist\ClearUserWatchlistJob\run(), and MediaWiki\JobQueue\Jobs\RefreshLinksJob\runForTitle().
| MediaWiki\JobQueue\Job::setMetadata | ( | $field, | |
| $value ) |
| string | $field | Key name to set the value for |
| mixed | $value | The value to set the field for |
Implements MediaWiki\JobQueue\RunnableJob.
Definition at line 168 of file Job.php.
References MediaWiki\JobQueue\Job\getMetadata().
| MediaWiki\JobQueue\Job::teardown | ( | $status | ) |
| MediaWiki\JobQueue\Job::toString | ( | ) |
Implements MediaWiki\JobQueue\RunnableJob.
Definition at line 361 of file Job.php.
References MediaWiki\JobQueue\Job\$command.
| MediaWiki\JobQueue\Job::workItemCount | ( | ) |
Implements MediaWiki\JobQueue\RunnableJob.
Reimplemented in MediaWiki\JobQueue\Jobs\HTMLCacheUpdateJob, and MediaWiki\JobQueue\Jobs\RefreshLinksJob.
| string MediaWiki\JobQueue\Job::$command |
Definition at line 30 of file Job.php.
Referenced by MediaWiki\JobQueue\Job\__construct(), MediaWiki\Watchlist\WatchlistExpiryJob\__construct(), MediaWiki\JobQueue\Job\getType(), and MediaWiki\JobQueue\Job\toString().
|
protected |
Text for error that occurred last.
Definition at line 45 of file Job.php.
Referenced by MediaWiki\JobQueue\Job\getLastError(), and MediaWiki\JobQueue\Job\setLastError().
|
protected |
| array MediaWiki\JobQueue\Job::$metadata = [] |
Additional queue metadata.
Definition at line 36 of file Job.php.
Referenced by MediaWiki\JobQueue\Job\getMetadata().
| array MediaWiki\JobQueue\Job::$params |
Array of job parameters.
Definition at line 33 of file Job.php.
Referenced by MediaWiki\JobQueue\Job\__construct(), MediaWiki\Watchlist\ActivityUpdateJob\__construct(), MediaWiki\Mail\EmaillingJob\__construct(), MediaWiki\JobQueue\Jobs\AssembleUploadChunksJob\__construct(), MediaWiki\JobQueue\Jobs\CdnPurgeJob\__construct(), MediaWiki\JobQueue\Jobs\DuplicateJob\__construct(), MediaWiki\JobQueue\Jobs\NullJob\__construct(), MediaWiki\JobQueue\Jobs\PublishStashedFileJob\__construct(), MediaWiki\JobQueue\Jobs\UploadFromUrlJob\__construct(), MediaWiki\Page\DeletePageJob\__construct(), MediaWiki\User\Options\UserOptionsUpdateJob\__construct(), MediaWiki\User\UserEditCountInitJob\__construct(), MediaWiki\User\UserGroupExpiryJob\__construct(), MediaWiki\Watchlist\ClearUserWatchlistJob\__construct(), MediaWiki\Watchlist\ClearWatchlistNotificationsJob\__construct(), MediaWiki\JobQueue\Jobs\ParsoidCachePrewarmJob\__construct(), MediaWiki\JobQueue\Jobs\RefreshLinksJob\__construct(), MediaWiki\JobQueue\Jobs\CategoryCountUpdateJob\__construct(), MediaWiki\JobQueue\Jobs\CategoryMembershipChangeJob\__construct(), MediaWiki\JobQueue\Jobs\DoubleRedirectJob\__construct(), MediaWiki\Watchlist\WatchlistExpiryJob\__construct(), MediaWiki\JobQueue\Jobs\HTMLCacheUpdateJob\__construct(), MediaWiki\JobQueue\Jobs\ThumbnailRenderJob\__construct(), MediaWiki\Page\DeleteLinksJob\__construct(), MediaWiki\RecentChanges\RecentChangesUpdateJob\__construct(), MediaWiki\RenameUser\Job\RenameUserTableJob\__construct(), MediaWiki\RecentChanges\RecentChangeNotifyJob\__construct(), MediaWiki\RenameUser\Job\RenameUserDerivedJob\__construct(), MediaWiki\JobQueue\Job\getParams(), MediaWiki\JobQueue\Jobs\RefreshLinksJob\newDynamic(), MediaWiki\JobQueue\Jobs\HTMLCacheUpdateJob\newForBacklinks(), MediaWiki\JobQueue\Jobs\RefreshLinksJob\newPrioritized(), and MediaWiki\JobQueue\Jobs\NullJob\run().
|
protected |
Expensive jobs may set this to true.
Definition at line 42 of file Job.php.
Referenced by MediaWiki\JobQueue\Job\ignoreDuplicates().
|
protected |
|
protected |
Definition at line 39 of file Job.php.
Referenced by MediaWiki\Watchlist\ActivityUpdateJob\__construct(), MediaWiki\JobQueue\Jobs\HTMLCacheUpdateJob\__construct(), MediaWiki\JobQueue\Jobs\ThumbnailRenderJob\__construct(), MediaWiki\Page\DeleteLinksJob\__construct(), MediaWiki\RecentChanges\RecentChangesUpdateJob\__construct(), MediaWiki\RenameUser\Job\RenameUserTableJob\__construct(), MediaWiki\RecentChanges\RecentChangeNotifyJob\__construct(), MediaWiki\RenameUser\Job\RenameUserDerivedJob\__construct(), MediaWiki\JobQueue\Jobs\DoubleRedirectJob\fixRedirects(), MediaWiki\JobQueue\Jobs\DoubleRedirectJob\getFinalDestination(), MediaWiki\JobQueue\Job\getTitle(), MediaWiki\JobQueue\Jobs\HTMLCacheUpdateJob\newForBacklinks(), MediaWiki\JobQueue\Jobs\CategoryMembershipChangeJob\notifyUpdatesForRevision(), MediaWiki\JobQueue\Jobs\HTMLCacheUpdateJob\run(), and MediaWiki\JobQueue\Jobs\RefreshLinksJob\run().