/**
* Class to both describe a background job and handle jobs.
- * This queue aspects of this class are now deprecated.
+ * The queue aspects of this class are now deprecated.
*
* @ingroup JobQueue
*/
* removed later on, when the first one is popped.
*
* @param $jobs array of Job objects
- * @deprecated 1.20
+ * @deprecated 1.21
*/
public static function batchInsert( $jobs ) {
return JobQueueGroup::singleton()->push( $jobs );
* large batches of jobs can cause slave lag.
*
* @param $jobs array of Job objects
- * @deprecated 1.20
+ * @deprecated 1.21
*/
public static function safeBatchInsert( $jobs ) {
return JobQueueGroup::singleton()->push( $jobs, JobQueue::QoS_Atomic );
}
+ /**
+ * Pop a job of a certain type. This tries less hard than pop() to
+ * actually find a job; it may be adversely affected by concurrent job
+ * runners.
+ *
+ * @param $type string
+ * @return Job
+ * @deprecated 1.21
+ */
+ public static function pop_type( $type ) {
+ return JobQueueGroup::singleton()->get( $type )->pop();
+ }
+
+ /**
+ * Pop a job off the front of the queue.
+ * This is subject to $wgJobTypesExcludedFromDefaultQueue.
+ *
+ * @return Job or false if there's no jobs
+ * @deprecated 1.21
+ */
+ public static function pop() {
+ return JobQueueGroup::singleton()->pop();
+ }
+
/*-------------------------------------------------------------------------
* Non-static functions
*------------------------------------------------------------------------*/
return $this->removeDuplicates;
}
+ /**
+ * Subclasses may need to override this to make duplication detection work
+ *
+ * @return Array Map of key/values
+ */
+ public function getDeduplicationInfo() {
+ $info = array(
+ 'type' => $this->getType(),
+ 'namespace' => $this->getTitle()->getNamespace(),
+ 'title' => $this->getTitle()->getDBkey(),
+ 'params' => $this->getParams()
+ );
+ // Identical jobs with different "root" jobs should count as duplicates
+ if ( is_array( $info['params'] ) ) {
+ unset( $info['params']['rootJobSignature'] );
+ unset( $info['params']['rootJobTimestamp'] );
+ }
+ return $info;
+ }
+
+ /**
+ * @param $key string A key that identifies the task
+ * @return Array
+ */
+ public static function newRootJobParams( $key ) {
+ return array(
+ 'rootJobSignature' => sha1( $key ),
+ 'rootJobTimestamp' => wfTimestampNow()
+ );
+ }
+
+ /**
+ * @return Array
+ */
+ public function getRootJobParams() {
+ return array(
+ 'rootJobSignature' => isset( $this->params['rootJobSignature'] )
+ ? $this->params['rootJobSignature']
+ : null,
+ 'rootJobTimestamp' => isset( $this->params['rootJobTimestamp'] )
+ ? $this->params['rootJobTimestamp']
+ : null
+ );
+ }
+
/**
* Insert a single job into the queue.
* @return bool true on success
- * @deprecated 1.20
+ * @deprecated 1.21
*/
public function insert() {
return JobQueueGroup::singleton()->push( $this );