MDL-66139 cachestore_redis: Fix connection problems when port is not set

Due to some changes in Redis 5 php extension Moodle fails to connect via TCP when
no port is set. It's fixed upstream in phpredis repo (version 5.0.0, 5.0.1 and
5.0.2 affected so far), but with this patch we'll send the right port anyway.
This commit is contained in:
Netica Informática 2019-08-16 18:03:50 +02:00 committed by Eloy Lafuente (stronk7)
parent 0dca957716
commit d17bf23e8a

View File

@ -150,7 +150,8 @@ class cachestore_redis extends cache_store implements cache_is_key_aware, cache_
*/
protected function new_redis($server, $prefix = '', $password = '') {
$redis = new Redis();
$port = null;
// Check if it isn't a Unix socket to set default port.
$port = ($server[0] === '/') ? null : 6379;
if (strpos($server, ':')) {
$serverconf = explode(':', $server);
$server = $serverconf[0];