Skip to content
Snippets Groups Projects
Commit 116f1dfe authored by Jeremy Andrews's avatar Jeremy Andrews
Browse files

Issue #2422871 by Jeremy: Undefined offset: 1 in dmemcache_connect()

parent c031d082
No related merge requests found
......@@ -580,7 +580,10 @@ function dmemcache_connect($memcache, $server, $connection) {
$extension = dmemcache_extension();
list($host, $port) = explode(':', $server);
@list($host, $port) = explode(':', trim($server));
if (empty($host)) {
register_shutdown_function('watchdog', 'memcache', 'You have specified an invalid address of "!server" in settings.php. Please review README.txt for proper configuration.', array('!server' => $server, '!ip' => t('127.0.0.1:11211'), '!host' => t('localhost:11211'), '!socket' => t('unix:///path/to/socket')), WATCHDOG_WARNING);
}
if ($extension == 'Memcache') {
// Allow persistent connection via Memcache extension -- note that this
......@@ -597,6 +600,9 @@ function dmemcache_connect($memcache, $server, $connection) {
$host = $server;
$port = 0;
}
else if (!isset($port)) {
register_shutdown_function('watchdog', 'memcache', 'You have specified an invalid address of "!server" in settings.php which does not include a port. Please review README.txt for proper configuration. You must specify both a server address and port such as "!ip" or "!host", or a unix socket such as "!socket".', array('!server' => $server, '!ip' => t('127.0.0.1:11211'), '!host' => t('localhost:11211'), '!socket' => t('unix:///path/to/socket')), WATCHDOG_WARNING);
}
// When using the PECL memcache extension, we must use ->(p)connect
// for the first connection.
......@@ -629,6 +635,9 @@ function dmemcache_connect($memcache, $server, $connection) {
$host = substr($server, 7);
$port = 0;
}
else if (!isset($port)) {
register_shutdown_function('watchdog', 'memcache', 'You have specified an invalid address of "!server" in settings.php which does not include a port. Please review README.txt for proper configuration. You must specify both a server address and port such as "!ip" or "!host", or a unix socket such as "!socket".', array('!server' => $server, '!ip' => t('127.0.0.1:11211'), '!host' => t('localhost:11211'), '!socket' => t('unix:///path/to/socket')), WATCHDOG_WARNING);
}
$rc = $memcache->addServer($host, $port);
}
else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment