Skip to content

Commit ae38bda

Browse files
bug symfony#41099 [Cache] Check if phpredis version is compatible with stream parameter (nicolassing)
This PR was merged into the 4.4 branch. Discussion ---------- [Cache] Check if phpredis version is compatible with stream parameter | Q | A | ------------- | --- | Branch? | 5.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | License | MIT If you use phpredis <5.3.0, you can't connect to Redis since symfony/cache 5.2.7 Fixes symfony#41110 Commits ------- 841d85a Check redis extension version
2 parents c276f0d + 841d85a commit ae38bda

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public static function createConnection($dsn, array $options = [])
188188
}
189189

190190
try {
191-
@$redis->{$connect}($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout'], ['stream' => $params['ssl'] ?? null]);
191+
@$redis->{$connect}($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout'], ...\defined('Redis::SCAN_PREFIX') ? [['stream' => $params['ssl'] ?? null]] : []);
192192

193193
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
194194
$isConnected = $redis->isConnected();
@@ -251,7 +251,7 @@ public static function createConnection($dsn, array $options = [])
251251
}
252252

253253
try {
254-
$redis = new $class(null, $hosts, $params['timeout'], $params['read_timeout'], (bool) $params['persistent'], $params['auth'] ?? '', $params['ssl'] ?? null);
254+
$redis = new $class(null, $hosts, $params['timeout'], $params['read_timeout'], (bool) $params['persistent'], $params['auth'] ?? '', ...\defined('Redis::SCAN_PREFIX') ? [$params['ssl'] ?? null] : []);
255255
} catch (\RedisClusterException $e) {
256256
throw new InvalidArgumentException(sprintf('Redis connection "%s" failed: ', $dsn).$e->getMessage());
257257
}

0 commit comments

Comments
 (0)