Merge "SpecialUserlogin: Error out when attempting to create a username with a '#'"
[lhc/web/wiklou.git] / includes / jobqueue / JobQueueRedis.php
index c785cb2..6739a84 100644 (file)
@@ -71,12 +71,6 @@ class JobQueueRedis extends JobQueue {
        /** @var string Key to prefix the queue keys with (used for testing) */
        protected $key;
 
-       /**
-        * @var null|int maximum seconds between execution of periodic tasks.  Used to speed up
-        * testing but should otherwise be left unset.
-        */
-       protected $maximumPeriodicTaskSeconds;
-
        /**
         * @params include:
         *   - redisConfig : An array of parameters to RedisConnectionPool::__construct().
@@ -85,10 +79,6 @@ class JobQueueRedis extends JobQueue {
         *                   If a hostname is specified but no port, the standard port number
         *                   6379 will be used. Required.
         *   - compression : The type of compression to use; one of (none,gzip).
-        *   - maximumPeriodicTaskSeconds : Maximum seconds between check periodic tasks.  Set to
-        *                   force faster execution of periodic tasks for inegration tests that
-        *                   rely on checkDelay.  Without this the integration tests are very very
-        *                   slow.  This really shouldn't be set in production.
         * @param array $params
         */
        public function __construct( array $params ) {
@@ -97,8 +87,6 @@ class JobQueueRedis extends JobQueue {
                $this->server = $params['redisServer'];
                $this->compression = isset( $params['compression'] ) ? $params['compression'] : 'none';
                $this->redisPool = RedisConnectionPool::singleton( $params['redisConfig'] );
-               $this->maximumPeriodicTaskSeconds = isset( $params['maximumPeriodicTaskSeconds'] ) ?
-                       $params['maximumPeriodicTaskSeconds'] : null;
        }
 
        protected function supportedOrders() {
@@ -194,8 +182,8 @@ class JobQueueRedis extends JobQueue {
        /**
         * @see JobQueue::doBatchPush()
         * @param array $jobs
-        * @param $flags
-        * @return bool
+        * @param int $flags
+        * @return void
         * @throws JobQueueError
         */
        protected function doBatchPush( array $jobs, $flags ) {
@@ -211,7 +199,7 @@ class JobQueueRedis extends JobQueue {
                }
 
                if ( !count( $items ) ) {
-                       return true; // nothing to do
+                       return; // nothing to do
                }
 
                $conn = $this->getConnection();
@@ -235,16 +223,14 @@ class JobQueueRedis extends JobQueue {
                        if ( $failed > 0 ) {
                                wfDebugLog( 'JobQueueRedis', "Could not insert {$failed} {$this->type} job(s)." );
 
-                               return false;
+                               throw new RedisException( "Could not insert {$failed} {$this->type} job(s)." );
                        }
-                       JobQueue::incrStats( 'job-insert', $this->type, count( $items ) );
+                       JobQueue::incrStats( 'job-insert', $this->type, count( $items ), $this->wiki );
                        JobQueue::incrStats( 'job-insert-duplicate', $this->type,
-                               count( $items ) - $failed - $pushed );
+                               count( $items ) - $failed - $pushed, $this->wiki );
                } catch ( RedisException $e ) {
                        $this->throwRedisException( $conn, $e );
                }
-
-               return true;
        }
 
        /**
@@ -331,7 +317,7 @@ LUA;
                                        break; // no jobs; nothing to do
                                }
 
-                               JobQueue::incrStats( 'job-pop', $this->type );
+                               JobQueue::incrStats( 'job-pop', $this->type, 1, $this->wiki );
                                $item = $this->unserialize( $blob );
                                if ( $item === false ) {
                                        wfDebugLog( 'JobQueueRedis', "Could not unserialize {$this->type} job." );
@@ -350,7 +336,7 @@ LUA;
 
        /**
         * @param RedisConnRef $conn
-        * @return array serialized string or false
+        * @return array Serialized string or false
         * @throws RedisException
         */
        protected function popAndDeleteBlob( RedisConnRef $conn ) {
@@ -383,7 +369,7 @@ LUA;
 
        /**
         * @param RedisConnRef $conn
-        * @return array serialized string or false
+        * @return array Serialized string or false
         * @throws RedisException
         */
        protected function popAndAcquireBlob( RedisConnRef $conn ) {
@@ -614,8 +600,8 @@ LUA;
        /**
         * This function should not be called outside JobQueueRedis
         *
-        * @param $uid string
-        * @param $conn RedisConnRef
+        * @param string $uid
+        * @param RedisConnRef $conn
         * @return Job|bool Returns false if the job does not exist
         * @throws MWException|JobQueueError
         */
@@ -715,8 +701,8 @@ LUA;
                        if ( $res ) {
                                list( $released, $abandoned, $pruned, $undelayed ) = $res;
                                $count += $released + $pruned + $undelayed;
-                               JobQueue::incrStats( 'job-recycle', $this->type, $released );
-                               JobQueue::incrStats( 'job-abandon', $this->type, $abandoned );
+                               JobQueue::incrStats( 'job-recycle', $this->type, $released, $this->wiki );
+                               JobQueue::incrStats( 'job-abandon', $this->type, $abandoned, $this->wiki );
                        }
                } catch ( RedisException $e ) {
                        $this->throwRedisException( $conn, $e );
@@ -738,10 +724,7 @@ LUA;
                }
                $period = min( $periods );
                $period = max( $period, 30 ); // sanity
-               // Support override for faster testing
-               if ( $this->maximumPeriodicTaskSeconds !== null ) {
-                       $period = min( $period, $this->maximumPeriodicTaskSeconds );
-               }
+
                return array(
                        'recyclePruneAndUndelayJobs' => array(
                                'callback' => array( $this, 'recyclePruneAndUndelayJobs' ),
@@ -773,7 +756,7 @@ LUA;
        }
 
        /**
-        * @param $fields array
+        * @param array $fields
         * @return Job|bool
         */
        protected function getJobFromFields( array $fields ) {
@@ -840,8 +823,8 @@ LUA;
        }
 
        /**
-        * @param $conn RedisConnRef
-        * @param $e RedisException
+        * @param RedisConnRef $conn
+        * @param RedisException $e
         * @throws JobQueueError
         */
        protected function throwRedisException( RedisConnRef $conn, $e ) {
@@ -850,8 +833,8 @@ LUA;
        }
 
        /**
-        * @param $prop string
-        * @param $type string|null
+        * @param string $prop
+        * @param string|null $type
         * @return string
         */
        private function getQueueKey( $prop, $type = null ) {
@@ -865,7 +848,7 @@ LUA;
        }
 
        /**
-        * @param $key string
+        * @param string $key
         * @return void
         */
        public function setTestingPrefix( $key ) {