From 0cf91ab6b4f409c712958efc7c41bb5fbe64869c Mon Sep 17 00:00:00 2001 From: Rik van der Heijden Date: Thu, 29 Dec 2022 07:29:58 +0100 Subject: [PATCH] fix for caching without auth parameter, broken by #48711, fix for #48813 --- .../Component/Cache/Traits/RedisTrait.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Cache/Traits/RedisTrait.php b/src/Symfony/Component/Cache/Traits/RedisTrait.php index 8e26cfc1f23e5..85dc306c05fb0 100644 --- a/src/Symfony/Component/Cache/Traits/RedisTrait.php +++ b/src/Symfony/Component/Cache/Traits/RedisTrait.php @@ -206,8 +206,11 @@ public static function createConnection(string $dsn, array $options = []) if (!isset($params['redis_sentinel'])) { break; } - - $sentinel = new \RedisSentinel($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout'], ...\defined('Redis::OPT_NULL_MULTIBULK_AS_NULL') ? [$params['auth'] ?? ''] : []); + $extra = []; + if (\defined('Redis::OPT_NULL_MULTIBULK_AS_NULL') && isset($params['auth'])) { + $extra = [$params['auth']]; + } + $sentinel = new \RedisSentinel($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout'], ...$extra); if ($address = $sentinel->getMasterAddrByName($params['redis_sentinel'])) { [$host, $port] = $address; @@ -219,10 +222,13 @@ public static function createConnection(string $dsn, array $options = []) } try { - @$redis->{$connect}($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout'], ...\defined('Redis::SCAN_PREFIX') ? [[ - 'auth' => $params['auth'] ?? '', + $extra = [ 'stream' => $params['ssl'] ?? null, - ]] : []); + ]; + if (isset($params['auth'])) { + $extra['auth'] = $params['auth']; + } + @$redis->{$connect}($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout'], ...\defined('Redis::SCAN_PREFIX') ? [$extra] : []); set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; }); try {