Merge "Add missing subjectspace pages to watchlist on update."
[lhc/web/wiklou.git] / includes / job / JobQueueDB.php
index 59d3de1..79ff4e8 100644 (file)
@@ -37,7 +37,8 @@ class JobQueueDB extends JobQueue {
        /** @var BagOStuff */
        protected $cache;
 
-       protected $cluster = false; // string; name of an external DB cluster
+       /** @var bool|string Name of an external DB cluster. False if not set */
+       protected $cluster = false;
 
        /**
         * Additional parameters include:
@@ -45,7 +46,7 @@ class JobQueueDB extends JobQueue {
         *               If not specified, the primary DB cluster for the wiki will be used.
         *               This can be overridden with a custom cluster so that DB handles will
         *               be retrieved via LBFactory::getExternalLB() and getConnection().
-        * @param $params array
+        * @param array $params
         */
        protected function __construct( array $params ) {
                global $wgMemc;
@@ -94,7 +95,7 @@ class JobQueueDB extends JobQueue {
 
        /**
         * @see JobQueue::doGetSize()
-        * @return integer
+        * @return int
         */
        protected function doGetSize() {
                $key = $this->getCacheKey( 'size' );
@@ -120,7 +121,7 @@ class JobQueueDB extends JobQueue {
 
        /**
         * @see JobQueue::doGetAcquiredCount()
-        * @return integer
+        * @return int
         */
        protected function doGetAcquiredCount() {
                if ( $this->claimTTL <= 0 ) {
@@ -150,7 +151,7 @@ class JobQueueDB extends JobQueue {
 
        /**
         * @see JobQueue::doGetAbandonedCount()
-        * @return integer
+        * @return int
         * @throws MWException
         */
        protected function doGetAbandonedCount() {
@@ -209,12 +210,12 @@ class JobQueueDB extends JobQueue {
        /**
         * This function should *not* be called outside of JobQueueDB
         *
-        * @param DatabaseBase $dbw
+        * @param IDatabase $dbw
         * @param array $jobs
         * @param int $flags
         * @param string $method
-        * @return boolean
-        * @throws type
+        * @throws DBError
+        * @return bool
         */
        public function doBatchPushInternal( IDatabase $dbw, array $jobs, $flags, $method ) {
                if ( !count( $jobs ) ) {
@@ -258,8 +259,11 @@ class JobQueueDB extends JobQueue {
                                $dbw->insert( 'job', $rowBatch, $method );
                        }
                        JobQueue::incrStats( 'job-insert', $this->type, count( $rows ) );
-                       JobQueue::incrStats( 'job-insert-duplicate', $this->type,
-                               count( $rowSet ) + count( $rowList ) - count( $rows ) );
+                       JobQueue::incrStats(
+                               'job-insert-duplicate',
+                               $this->type,
+                               count( $rowSet ) + count( $rowList ) - count( $rows )
+                       );
                } catch ( DBError $e ) {
                        if ( $flags & self::QOS_ATOMIC ) {
                                $dbw->rollback( $method );
@@ -320,7 +324,6 @@ class JobQueueDB extends JobQueue {
                                $job = Job::factory( $row->job_cmd, $title,
                                        self::extractBlob( $row->job_params ), $row->job_id );
                                $job->metadata['id'] = $row->job_id;
-                               $job->id = $row->job_id; // XXX: work around broken subclasses
                                break; // done
                        } while ( true );
                } catch ( DBError $e ) {
@@ -336,7 +339,7 @@ class JobQueueDB extends JobQueue {
         * @param string $uuid 32 char hex string
         * @param $rand integer Random unsigned integer (31 bits)
         * @param bool $gte Search for job_random >= $random (otherwise job_random <= $random)
-        * @return Row|false
+        * @return stdClass|bool Row|false
         */
        protected function claimRandom( $uuid, $rand, $gte ) {
                $dbw = $this->getMasterDB();
@@ -386,6 +389,7 @@ class JobQueueDB extends JobQueue {
                                        continue; // use job_random
                                }
                        }
+
                        if ( $row ) { // claim the job
                                $dbw->update( 'job', // update by PK
                                        array(
@@ -412,7 +416,7 @@ class JobQueueDB extends JobQueue {
         * Reserve a row with a single UPDATE without holding row locks over RTTs...
         *
         * @param string $uuid 32 char hex string
-        * @return Row|false
+        * @return stdClass|bool Row|false
         */
        protected function claimOldest( $uuid ) {
                $dbw = $this->getMasterDB();
@@ -557,7 +561,7 @@ class JobQueueDB extends JobQueue {
        }
 
        /**
-        * @return Array
+        * @return array
         */
        protected function doGetPeriodicTasks() {
                return array(
@@ -591,11 +595,9 @@ class JobQueueDB extends JobQueue {
                                        $job = Job::factory(
                                                $row->job_cmd,
                                                Title::makeTitle( $row->job_namespace, $row->job_title ),
-                                               strlen( $row->job_params ) ? unserialize( $row->job_params ) : false,
-                                               $row->job_id
+                                               strlen( $row->job_params ) ? unserialize( $row->job_params ) : false
                                        );
                                        $job->metadata['id'] = $row->job_id;
-                                       $job->id = $row->job_id; // XXX: work around broken subclasses
                                        return $job;
                                }
                        );
@@ -639,7 +641,7 @@ class JobQueueDB extends JobQueue {
        /**
         * Recycle or destroy any jobs that have been claimed for too long
         *
-        * @return integer Number of jobs recycled/deleted
+        * @return int Number of jobs recycled/deleted
         */
        public function recycleAndDeleteStaleJobs() {
                $now = time();
@@ -721,7 +723,7 @@ class JobQueueDB extends JobQueue {
        }
 
        /**
-        * @param $job Job
+        * @param Job $job
         * @return array
         */
        protected function insertFields( Job $job ) {
@@ -745,6 +747,7 @@ class JobQueueDB extends JobQueue {
        }
 
        /**
+        * @throws JobQueueConnectionError
         * @return DBConnRef
         */
        protected function getSlaveDB() {
@@ -756,6 +759,7 @@ class JobQueueDB extends JobQueue {
        }
 
        /**
+        * @throws JobQueueConnectionError
         * @return DBConnRef
         */
        protected function getMasterDB() {
@@ -779,6 +783,7 @@ class JobQueueDB extends JobQueue {
        }
 
        /**
+        * @param $property
         * @return string
         */
        private function getCacheKey( $property ) {