Consistently use '@deprecated since <version>'
[lhc/web/wiklou.git] / includes / clientpool / RedisConnectionPool.php
index 983d90a..15f0a47 100644 (file)
@@ -48,7 +48,7 @@ class RedisConnectionPool {
        protected $password;
        /** @var bool Whether connections persist */
        protected $persistent;
-       /** @var integer Serializer to use (Redis::SERIALIZER_*) */
+       /** @var int Serializer to use (Redis::SERIALIZER_*) */
        protected $serializer;
        /** @} */
 
@@ -127,7 +127,7 @@ class RedisConnectionPool {
                // Initialize the object at the hash as needed...
                if ( !isset( self::$instances[$id] ) ) {
                        self::$instances[$id] = new self( $options );
-                       wfDebug( "Creating a new " . __CLASS__ . " instance with id $id." );
+                       wfDebug( "Creating a new " . __CLASS__ . " instance with id $id.\n" );
                }
 
                return self::$instances[$id];
@@ -153,7 +153,7 @@ class RedisConnectionPool {
                        } else {
                                // Server is dead
                                wfDebug( "server $server is marked down for another " .
-                                       ( $this->downServers[$server] - $now ) . " seconds, can't get connection" );
+                                       ( $this->downServers[$server] - $now ) . " seconds, can't get connection\n" );
 
                                return false;
                        }
@@ -277,9 +277,24 @@ class RedisConnectionPool {
         * @param string $server
         * @param RedisConnRef $cref
         * @param RedisException $e
+        * @deprecated since 1.23
         */
        public function handleException( $server, RedisConnRef $cref, RedisException $e ) {
-               wfDebugLog( 'redis', "Redis exception on server $server: " . $e->getMessage() );
+               return $this->handleError( $cref, $e );
+       }
+
+       /**
+        * The redis extension throws an exception in response to various read, write
+        * and protocol errors. Sometimes it also closes the connection, sometimes
+        * not. The safest response for us is to explicitly destroy the connection
+        * object and let it be reopened during the next request.
+        *
+        * @param RedisConnRef $cref
+        * @param RedisException $e
+        */
+       public function handleError( RedisConnRef $cref, RedisException $e ) {
+               $server = $cref->getServer();
+               wfDebugLog( 'redis', "Redis exception on server $server: " . $e->getMessage() . "\n" );
                foreach ( $this->connections[$server] as $key => $connection ) {
                        if ( $cref->isConnIdentical( $connection['conn'] ) ) {
                                $this->idlePoolSize -= $connection['free'] ? 1 : 0;
@@ -393,7 +408,7 @@ class RedisConnRef {
        /**
         * @param string $script
         * @param array $params
-        * @param integer $numKeys
+        * @param int $numKeys
         * @return mixed
         * @throws RedisException
         */
@@ -406,7 +421,7 @@ class RedisConnRef {
                $conn->clearLastError();
                $res = $conn->evalSha( $sha1, $params, $numKeys );
                // If we got a permission error reply that means that (a) we are not in
-               // multi()/pipeline() and (b) some connection problem likely occured. If
+               // multi()/pipeline() and (b) some connection problem likely occurred. If
                // the password the client gave was just wrong, an exception should have
                // been thrown back in getConnection() previously.
                if ( preg_match( '/^ERR operation not permitted\b/', $conn->getLastError() ) ) {