Merge "Add and use Title::getOtherPage()"
[lhc/web/wiklou.git] / includes / jobqueue / JobQueueFederated.php
index d6f9560..4186204 100644 (file)
@@ -64,7 +64,7 @@ class JobQueueFederated extends JobQueue {
        const CACHE_TTL_LONG = 300; // integer; seconds to cache info that is kept up to date
 
        /**
-        * @params include:
+        * @param array $params Possible keys:
         *  - sectionsByWiki      : A map of wiki IDs to section names.
         *                          Wikis will default to using the section "default".
         *  - partitionsBySection : Map of section names to maps of (partition name => weight).
@@ -72,7 +72,7 @@ class JobQueueFederated extends JobQueue {
         *                          have explicitly defined sections.
         *  - configByPartition   : Map of queue partition names to configuration arrays.
         *                          These configuration arrays are passed to JobQueue::factory().
-        *                          The options set here are overriden by those passed to this
+        *                          The options set here are overridden by those passed to this
         *                          the federated queue itself (e.g. 'order' and 'claimTTL').
         *  - partitionsNoPush    : List of partition names that can handle pop() but not push().
         *                          This can be used to migrate away from a certain partition.
@@ -80,7 +80,6 @@ class JobQueueFederated extends JobQueue {
         *                          different partition queues. This improves availability
         *                          during failure, at the cost of added latency and somewhat
         *                          less reliable job de-duplication mechanisms.
-        * @param array $params
         * @throws MWException
         */
        protected function __construct( array $params ) {
@@ -282,7 +281,7 @@ class JobQueueFederated extends JobQueue {
                        }
                        if ( $ok ) {
                                $key = $this->getCacheKey( 'empty' );
-                               $this->cache->set( $key, 'false', JobQueueDB::CACHE_TTL_LONG );
+                               $this->cache->set( $key, 'false', self::CACHE_TTL_LONG );
                        } else {
                                if ( !$partitionRing->ejectFromLiveRing( $partition, 5 ) ) { // blacklist
                                        throw new JobQueueError( "Could not insert job(s), no partitions available." );
@@ -304,7 +303,7 @@ class JobQueueFederated extends JobQueue {
                        }
                        if ( $ok ) {
                                $key = $this->getCacheKey( 'empty' );
-                               $this->cache->set( $key, 'false', JobQueueDB::CACHE_TTL_LONG );
+                               $this->cache->set( $key, 'false', self::CACHE_TTL_LONG );
                        } else {
                                if ( !$partitionRing->ejectFromLiveRing( $partition, 5 ) ) { // blacklist
                                        throw new JobQueueError( "Could not insert job(s), no partitions available." );
@@ -317,13 +316,6 @@ class JobQueueFederated extends JobQueue {
        }
 
        protected function doPop() {
-               $key = $this->getCacheKey( 'empty' );
-
-               $isEmpty = $this->cache->get( $key );
-               if ( $isEmpty === 'true' ) {
-                       return false;
-               }
-
                $partitionsTry = $this->partitionRing->getLiveLocationWeights(); // (partition => weight)
 
                $failed = 0;
@@ -352,7 +344,8 @@ class JobQueueFederated extends JobQueue {
                }
                $this->throwErrorIfAllPartitionsDown( $failed );
 
-               $this->cache->set( $key, 'true', JobQueueDB::CACHE_TTL_LONG );
+               $key = $this->getCacheKey( 'empty' );
+               $this->cache->set( $key, 'true', self::CACHE_TTL_LONG );
 
                return false;
        }