Merge "tests: Remove unused TableCleanupTest class"
[lhc/web/wiklou.git] / includes / clientpool / RedisConnectionPool.php
index ec0573e..1b9f9b3 100644 (file)
@@ -79,11 +79,11 @@ class RedisConnectionPool implements LoggerAwareInterface {
 
        /**
         * @param array $options
-        * @throws MWException
+        * @throws Exception
         */
        protected function __construct( array $options ) {
                if ( !class_exists( 'Redis' ) ) {
-                       throw new MWException( __CLASS__ . ' requires a Redis client library. ' .
+                       throw new Exception( __CLASS__ . ' requires a Redis client library. ' .
                                'See https://www.mediawiki.org/wiki/Redis#Setup' );
                }
                if ( isset( $options['logger'] ) ) {
@@ -102,7 +102,7 @@ class RedisConnectionPool implements LoggerAwareInterface {
                } elseif ( $options['serializer'] === 'none' ) {
                        $this->serializer = Redis::SERIALIZER_NONE;
                } else {
-                       throw new MWException( "Invalid serializer specified." );
+                       throw new InvalidArgumentException( "Invalid serializer specified." );
                }
        }
 
@@ -166,6 +166,14 @@ class RedisConnectionPool implements LoggerAwareInterface {
                return self::$instances[$id];
        }
 
+       /**
+        * Destroy all singleton() instances
+        * @since 1.27
+        */
+       public static function destroySingletons() {
+               self::$instances = array();
+       }
+
        /**
         * Get a connection to a redis server. Based on code in RedisBagOStuff.php.
         *
@@ -219,7 +227,9 @@ class RedisConnectionPool implements LoggerAwareInterface {
                        // TCP connection
                        $hostPort = IP::splitHostAndPort( $server );
                        if ( !$server || !$hostPort ) {
-                               throw new MWException( __CLASS__ . ": invalid configured server \"$server\"" );
+                               throw new InvalidArgumentException(
+                                       __CLASS__ . ": invalid configured server \"$server\""
+                               );
                        }
                        list( $host, $port ) = $hostPort;
                        if ( $port === false ) {
@@ -442,7 +452,9 @@ class RedisConnRef {
         * @param Redis $conn
         * @param LoggerInterface $logger
         */
-       public function __construct( RedisConnectionPool $pool, $server, Redis $conn, LoggerInterface $logger ) {
+       public function __construct(
+               RedisConnectionPool $pool, $server, Redis $conn, LoggerInterface $logger
+       ) {
                $this->pool = $pool;
                $this->server = $server;
                $this->conn = $conn;