X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fjobqueue%2FJob.php;h=3e23391cdf0e488a9010351ae3837663b0b35da1;hb=59ebff658ce912c1b0e7ef8d8f9bfec5a4e17b39;hp=b971bd566fb902044a41767e165373ba58f9cf9e;hpb=112892455f2d42f4981760d53e404af8444b9ec5;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/jobqueue/Job.php b/includes/jobqueue/Job.php index b971bd566f..3e23391cdf 100644 --- a/includes/jobqueue/Job.php +++ b/includes/jobqueue/Job.php @@ -144,6 +144,14 @@ abstract class Job implements IJobSpecification { : null; } + /** + * @return int|null UNIX timestamp of when the job was runnable, or null + * @since 1.26 + */ + public function getReadyTimestamp() { + return $this->getReleaseTimestamp() ?: $this->getQueuedTimestamp(); + } + /** * Whether the queue should reject insertion of this job if a duplicate exists * @@ -206,15 +214,27 @@ abstract class Job implements IJobSpecification { } /** + * 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. + * * @see JobQueue::deduplicateRootJob() + * * @param string $key A key that identifies the task * @return array Map of: + * - rootJobIsSelf : true * - rootJobSignature : hash (e.g. SHA1) that identifies the task * - rootJobTimestamp : TS_MW timestamp of this instance of the task * @since 1.21 */ public static function newRootJobParams( $key ) { return array( + 'rootJobIsSelf' => true, 'rootJobSignature' => sha1( $key ), 'rootJobTimestamp' => wfTimestampNow() ); @@ -246,6 +266,14 @@ abstract class Job implements IJobSpecification { && isset( $this->params['rootJobTimestamp'] ); } + /** + * @see JobQueue::deduplicateRootJob() + * @return bool Whether this is job is a root job + */ + public function isRootJob() { + return $this->hasRootJobParams() && !empty( $this->params['rootJobIsSelf'] ); + } + /** * Insert a single job into the queue. * @return bool True on success