From 70e949bdc2bfb7d06c07955fc81505567bcf7818 Mon Sep 17 00:00:00 2001 From: Matthew Flaschen Date: Thu, 30 Jul 2015 17:38:42 -0400 Subject: [PATCH] Throw exception on falsy server in RedisConnectionPool. Surprisingly, IP::splitHostAndPort does not return false for these. Also, tweak documentation of splitHostAndPort. Bug: T107498 Change-Id: I4230b1e7ba0fa2d28be8de3e0e7b064e58f0579c --- includes/clientpool/RedisConnectionPool.php | 2 +- includes/utils/IP.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/clientpool/RedisConnectionPool.php b/includes/clientpool/RedisConnectionPool.php index 599fb6aa28..117bd2d851 100644 --- a/includes/clientpool/RedisConnectionPool.php +++ b/includes/clientpool/RedisConnectionPool.php @@ -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; diff --git a/includes/utils/IP.php b/includes/utils/IP.php index dfcbe7850f..ae3736aeec 100644 --- a/includes/utils/IP.php +++ b/includes/utils/IP.php @@ -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 ) === '[' ) { -- 2.20.1