* Added a missing @since tag.
Change-Id: I887d55074007551040eee486dbb9e8e44106e5a9
}
/**
- * Subclasses may need to override this to make duplication detection work
+ * 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.
*
* @return Array Map of key/values
* @since 1.21
}
/**
+ * @see JobQueue::deduplicateRootJob()
* @param string $key A key that identifies the task
* @return Array
* @since 1.21
}
/**
+ * @see JobQueue::deduplicateRootJob()
* @return Array
+ * @since 1.21
*/
public function getRootJobParams() {
return array(
);
}
+ /**
+ * @see JobQueue::deduplicateRootJob()
+ * @return bool
+ * @since 1.22
+ */
+ public function hasRootJobParams() {
+ return isset( $this->params['rootJobSignature'] )
+ && isset( $this->params['rootJobTimestamp'] );
+ }
+
/**
* Insert a single job into the queue.
* @return bool true on success
protected function doDeduplicateRootJob( Job $job ) {
global $wgMemc;
- $params = $job->getParams();
- if ( !isset( $params['rootJobSignature'] ) ) {
- throw new MWException( "Cannot register root job; missing 'rootJobSignature'." );
- } elseif ( !isset( $params['rootJobTimestamp'] ) ) {
- throw new MWException( "Cannot register root job; missing 'rootJobTimestamp'." );
+ if ( !$job->hasRootJobParams() ) {
+ throw new MWException( "Cannot register root job; missing parameters." );
}
+ $params = $job->getRootJobParams();
+
$key = $this->getRootJobCacheKey( $params['rootJobSignature'] );
// Callers should call batchInsert() and then this function so that if the insert
// fails, the de-duplication registration will be aborted. Since the insert is
protected function doIsRootJobOldDuplicate( Job $job ) {
global $wgMemc;
- $params = $job->getParams();
- if ( !isset( $params['rootJobSignature'] ) ) {
+ if ( !$job->hasRootJobParams() ) {
return false; // job has no de-deplication info
- } elseif ( !isset( $params['rootJobTimestamp'] ) ) {
- trigger_error( "Cannot check root job; missing 'rootJobTimestamp'." );
- return false;
}
+ $params = $job->getRootJobParams();
// Get the last time this root job was enqueued
$timestamp = $wgMemc->get( $this->getRootJobCacheKey( $params['rootJobSignature'] ) );
* @throws MWException
*/
protected function doDeduplicateRootJob( Job $job ) {
- $params = $job->getParams();
- if ( !isset( $params['rootJobSignature'] ) ) {
- throw new MWException( "Cannot register root job; missing 'rootJobSignature'." );
- } elseif ( !isset( $params['rootJobTimestamp'] ) ) {
- throw new MWException( "Cannot register root job; missing 'rootJobTimestamp'." );
+ if ( !$job->hasRootJobParams() ) {
+ throw new MWException( "Cannot register root job; missing parameters." );
}
+ $params = $job->getRootJobParams();
+
$key = $this->getRootJobCacheKey( $params['rootJobSignature'] );
$conn = $this->getConnection();