Skip to content

Commit 51bbdc8

Browse files
committed
bug #48816 [Cache] Fix for RedisAdapter without auth parameter (rikvdh)
This PR was merged into the 5.4 branch. Discussion ---------- [Cache] Fix for RedisAdapter without auth parameter | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #48813 | License | MIT | Doc PR | x Compatibility with Redis without auth was broken by #48711, this change fixes this. This applies for all versions (6.x as well). Commits ------- 0cf91ab fix for caching without auth parameter, broken by #48711, fix for #48813
2 parents 3502d7e + 0cf91ab commit 51bbdc8

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/Symfony/Component/Cache/Traits/RedisTrait.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,11 @@ public static function createConnection(string $dsn, array $options = [])
206206
if (!isset($params['redis_sentinel'])) {
207207
break;
208208
}
209-
210-
$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'] ?? ''] : []);
209+
$extra = [];
210+
if (\defined('Redis::OPT_NULL_MULTIBULK_AS_NULL') && isset($params['auth'])) {
211+
$extra = [$params['auth']];
212+
}
213+
$sentinel = new \RedisSentinel($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout'], ...$extra);
211214

212215
if ($address = $sentinel->getMasterAddrByName($params['redis_sentinel'])) {
213216
[$host, $port] = $address;
@@ -219,10 +222,13 @@ public static function createConnection(string $dsn, array $options = [])
219222
}
220223

221224
try {
222-
@$redis->{$connect}($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout'], ...\defined('Redis::SCAN_PREFIX') ? [[
223-
'auth' => $params['auth'] ?? '',
225+
$extra = [
224226
'stream' => $params['ssl'] ?? null,
225-
]] : []);
227+
];
228+
if (isset($params['auth'])) {
229+
$extra['auth'] = $params['auth'];
230+
}
231+
@$redis->{$connect}($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout'], ...\defined('Redis::SCAN_PREFIX') ? [$extra] : []);
226232

227233
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
228234
try {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy