Throw exception on falsy server in RedisConnectionPool.
authorMatthew Flaschen <mflaschen@wikimedia.org>
Thu, 30 Jul 2015 21:38:42 +0000 (17:38 -0400)
committerMatthew Flaschen <mflaschen@wikimedia.org>
Thu, 30 Jul 2015 21:40:21 +0000 (17:40 -0400)
Surprisingly, IP::splitHostAndPort does not return false for these.

Also, tweak documentation of splitHostAndPort.

Bug: T107498
Change-Id: I4230b1e7ba0fa2d28be8de3e0e7b064e58f0579c

includes/clientpool/RedisConnectionPool.php
includes/utils/IP.php

index 599fb6a..117bd2d 100644 (file)
@@ -218,7 +218,7 @@ class RedisConnectionPool implements LoggerAwareInterface {
                } else {
                        // TCP connection
                        $hostPort = IP::splitHostAndPort( $server );
-                       if ( !$hostPort ) {
+                       if ( !$server || !$hostPort ) {
                                throw new MWException( __CLASS__ . ": invalid configured server \"$server\"" );
                        }
                        list( $host, $port ) = $hostPort;
index dfcbe78..ae3736a 100644 (file)
@@ -240,7 +240,7 @@ class IP {
         * A bare IPv6 address is accepted despite the lack of square brackets.
         *
         * @param string $both The string with the host and port
-        * @return array
+        * @return array|false Array normally, false on certain failures
         */
        public static function splitHostAndPort( $both ) {
                if ( substr( $both, 0, 1 ) === '[' ) {