push( $jobs ); } /** * Insert a group of jobs into the queue. * * Same as batchInsert() but does not commit and can thus * be rolled-back as part of a larger transaction. However, * large batches of jobs can cause slave lag. * * @param $jobs array of Job objects * @deprecated 1.20 */ public static function safeBatchInsert( $jobs ) { return JobQueueGroup::singleton()->push( $jobs, JobQueue::QoS_Atomic ); } /*------------------------------------------------------------------------- * Non-static functions *------------------------------------------------------------------------*/ /** * @param $command * @param $title * @param $params array|bool * @param $id int */ public function __construct( $command, $title, $params = false, $id = 0 ) { $this->command = $command; $this->title = $title; $this->params = $params; $this->id = $id; $this->removeDuplicates = false; // expensive jobs may set this to true } /** * @return integer May be 0 for jobs stored outside the DB */ public function getId() { return $this->id; } /** * @return string */ public function getType() { return $this->command; } /** * @return Title */ public function getTitle() { return $this->title; } /** * @return array */ public function getParams() { return $this->params; } /** * @return bool */ public function ignoreDuplicates() { return $this->removeDuplicates; } /** * Insert a single job into the queue. * @return bool true on success * @deprecated 1.20 */ public function insert() { return JobQueueGroup::singleton()->push( $this ); } /** * @return string */ public function toString() { $paramString = ''; if ( $this->params ) { foreach ( $this->params as $key => $value ) { if ( $paramString != '' ) { $paramString .= ' '; } $paramString .= "$key=$value"; } } if ( is_object( $this->title ) ) { $s = "{$this->command} " . $this->title->getPrefixedDBkey(); if ( $paramString !== '' ) { $s .= ' ' . $paramString; } return $s; } else { return "{$this->command} $paramString"; } } protected function setLastError( $error ) { $this->error = $error; } public function getLastError() { return $this->error; } }