diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-06-04 07:31:04 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-06-04 07:58:39 +0200 |
commit | f6d65e533c62f6deb21342d4901ece24497b433e (patch) | |
tree | f28adf0362d14bcd448f7b65a7aaf38650f923aa /includes/jobqueue/JobSpecification.php | |
parent | c27b2e832fe25651ef2410fae85b41072aae7519 (diff) |
Update to MediaWiki 1.25.1
Diffstat (limited to 'includes/jobqueue/JobSpecification.php')
-rw-r--r-- | includes/jobqueue/JobSpecification.php | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/includes/jobqueue/JobSpecification.php b/includes/jobqueue/JobSpecification.php index 9fa7747f..42d2a39b 100644 --- a/includes/jobqueue/JobSpecification.php +++ b/includes/jobqueue/JobSpecification.php @@ -91,8 +91,8 @@ class JobSpecification implements IJobSpecification { /** @var Title */ protected $title; - /** @var bool Expensive jobs may set this to true */ - protected $ignoreDuplicates; + /** @var array */ + protected $opts; /** * @param string $type @@ -104,11 +104,12 @@ class JobSpecification implements IJobSpecification { $type, array $params, array $opts = array(), Title $title = null ) { $this->validateParams( $params ); + $this->validateParams( $opts ); $this->type = $type; $this->params = $params; $this->title = $title ?: Title::newMainPage(); - $this->ignoreDuplicates = !empty( $opts['removeDuplicates'] ); + $this->opts = $opts; } /** @@ -158,7 +159,7 @@ class JobSpecification implements IJobSpecification { * @return bool Whether only one of each identical set of jobs should be run */ public function ignoreDuplicates() { - return $this->ignoreDuplicates; + return !empty( $this->opts['removeDuplicates'] ); } /** @@ -186,4 +187,31 @@ class JobSpecification implements IJobSpecification { return $info; } + + /** + * @return array Field/value map that can immediately be serialized + * @since 1.25 + */ + public function toSerializableArray() { + return array( + 'type' => $this->type, + 'params' => $this->params, + 'opts' => $this->opts, + 'title' => array( + 'ns' => $this->title->getNamespace(), + 'key' => $this->title->getDbKey() + ) + ); + } + + /** + * @param array $map Field/value map + * @return JobSpecification + * @since 1.25 + */ + public static function newFromArray( array $map ) { + $title = Title::makeTitle( $map['title']['ns'], $map['title']['key'] ); + + return new self( $map['type'], $map['params'], $map['opts'], $title ); + } } |