Skip to content

[Cache] Fix for RedisAdapter without auth parameter #48816

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix for caching without auth parameter, broken by #48711, fix for #48813
  • Loading branch information
rikvdh committed Dec 29, 2022
commit 0cf91ab6b4f409c712958efc7c41bb5fbe64869c
16 changes: 11 additions & 5 deletions src/Symfony/Component/Cache/Traits/RedisTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down