Merge changes Ic13414f0,I26085bfc
[lhc/web/wiklou.git] / includes / job / Job.php
index bb6fb04..3f44a91 100644 (file)
  * @ingroup JobQueue
  */
 abstract class Job {
-       /**
-        * @var Title
-        */
-       var $title;
+       /** @var int Job identifier */
+       public $id;
+
+       /** @var string */
+       public $command;
 
-       var $command,
-               $params,
-               $id,
-               $removeDuplicates,
-               $error;
+       /** @var array|bool Array of job parameters or false if none */
+       public $params;
 
-       /** @var Array Additional queue metadata */
+       /** @var array Additional queue metadata */
        public $metadata = array();
 
+       /** @var Title */
+       protected $title;
+
+       /** @var bool Expensive jobs may set this to true */
+       protected $removeDuplicates;
+
+       /** @var string Text for error that occurred last */
+       protected $error;
+
        /*-------------------------------------------------------------------------
         * Abstract functions
         *------------------------------------------------------------------------*/
 
        /**
         * Run the job
-        * @return boolean success
+        * @return bool Success
         */
        abstract public function run();
 
@@ -60,7 +67,7 @@ abstract class Job {
         * Create the appropriate object to handle a specific job
         *
         * @param string $command Job command
-        * @param $title Title: Associated title
+        * @param Title $title Associated title
         * @param array|bool $params Job parameters
         * @param int $id Job identifier
         * @throws MWException
@@ -70,6 +77,7 @@ abstract class Job {
                global $wgJobClasses;
                if ( isset( $wgJobClasses[$command] ) ) {
                        $class = $wgJobClasses[$command];
+
                        return new $class( $title, $params, $id );
                }
                throw new MWException( "Invalid job command `{$command}`" );
@@ -84,7 +92,7 @@ abstract class Job {
         *
         * @param array $jobs of Job objects
         * @return bool
-        * @deprecated 1.21
+        * @deprecated since 1.21
         */
        public static function batchInsert( $jobs ) {
                return JobQueueGroup::singleton()->push( $jobs );
@@ -99,7 +107,7 @@ abstract class Job {
         *
         * @param array $jobs of Job objects
         * @return bool
-        * @deprecated 1.21
+        * @deprecated since 1.21
         */
        public static function safeBatchInsert( $jobs ) {
                return JobQueueGroup::singleton()->push( $jobs, JobQueue::QOS_ATOMIC );
@@ -112,7 +120,7 @@ abstract class Job {
         *
         * @param $type string
         * @return Job|bool Returns false if there are no jobs
-        * @deprecated 1.21
+        * @deprecated since 1.21
         */
        public static function pop_type( $type ) {
                return JobQueueGroup::singleton()->get( $type )->pop();
@@ -122,8 +130,8 @@ abstract class Job {
         * 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
+        * @return Job|bool False if there are no jobs
+        * @deprecated since 1.21
         */
        public static function pop() {
                return JobQueueGroup::singleton()->pop();
@@ -145,12 +153,13 @@ abstract class Job {
                $this->params = $params;
                $this->id = $id;
 
-               $this->removeDuplicates = false; // expensive jobs may set this to true
+               // expensive jobs may set this to true
+               $this->removeDuplicates = false;
        }
 
        /**
-        * @return integer May be 0 for jobs stored outside the DB
-        * @deprecated 1.22
+        * @return int May be 0 for jobs stored outside the DB
+        * @deprecated since 1.22
         */
        public function getId() {
                return $this->id;
@@ -178,7 +187,7 @@ abstract class Job {
        }
 
        /**
-        * @return integer|null UNIX timestamp to delay running this job until, otherwise null
+        * @return int|null UNIX timestamp to delay running this job until, otherwise null
         * @since 1.22
         */
        public function getReleaseTimestamp() {
@@ -208,7 +217,7 @@ abstract class Job {
         * only checked if ignoreDuplicates() returns true, meaning that duplicate
         * jobs are supposed to be ignored.
         *
-        * @return Array Map of key/values
+        * @return array Map of key/values
         * @since 1.21
         */
        public function getDeduplicationInfo() {
@@ -225,13 +234,14 @@ abstract class Job {
                        // Likewise for jobs with different delay times
                        unset( $info['params']['jobReleaseTimestamp'] );
                }
+
                return $info;
        }
 
        /**
         * @see JobQueue::deduplicateRootJob()
         * @param string $key A key that identifies the task
-        * @return Array
+        * @return array
         * @since 1.21
         */
        public static function newRootJobParams( $key ) {
@@ -243,7 +253,7 @@ abstract class Job {
 
        /**
         * @see JobQueue::deduplicateRootJob()
-        * @return Array
+        * @return array
         * @since 1.21
         */
        public function getRootJobParams() {
@@ -270,7 +280,7 @@ abstract class Job {
        /**
         * Insert a single job into the queue.
         * @return bool true on success
-        * @deprecated 1.21
+        * @deprecated since 1.21
         */
        public function insert() {
                return JobQueueGroup::singleton()->push( $this );
@@ -305,6 +315,7 @@ abstract class Job {
                        if ( $paramString !== '' ) {
                                $s .= ' ' . $paramString;
                        }
+
                        return $s;
                } else {
                        return "{$this->command} $paramString";