From 77399dd147b315b74e1cbad0dbe9677f98e780a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Netica=20Inform=C3=A1tica?= Date: Fri, 16 Aug 2019 18:03:50 +0200 Subject: [PATCH] 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. --- cache/stores/redis/lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cache/stores/redis/lib.php b/cache/stores/redis/lib.php index 83a58892e5b..35962002b95 100644 --- a/cache/stores/redis/lib.php +++ b/cache/stores/redis/lib.php @@ -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];