MDL-78004 cache: Fix deprecated null value in Redis connect

This commit is contained in:
Wehr Mario 2023-04-24 20:15:16 +02:00
parent 090baf556e
commit d7194d3de0

View File

@ -196,12 +196,16 @@ class cachestore_redis extends cache_store implements cache_is_key_aware, cache_
*/
protected function new_redis($server, $prefix = '', $password = '') {
$redis = new Redis();
// 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];
$port = $serverconf[1];
// Check for Unix socket.
if ($server[0] === '/') {
$port = 0;
} else {
$port = 6379; // No Unix socket so set default port.
if (strpos($server, ':')) { // Check for custom port.
$serverconf = explode(':', $server);
$server = $serverconf[0];
$port = $serverconf[1];
}
}
try {