Skip to content

Commit 42a80db

Browse files
pepehnicolas-grekas
authored andcommitted
[Messenger] Fix support for Redis Sentinel using php-redis 6.0.0
1 parent ff29a1a commit 42a80db

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php

+15-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,21 @@ public function __construct(array $options, \Redis|Relay|\RedisCluster $redis =
9494
} else {
9595
if (null !== $sentinelMaster) {
9696
$sentinelClass = \extension_loaded('redis') ? \RedisSentinel::class : Sentinel::class;
97-
$sentinelClient = new $sentinelClass($host, $port, $options['timeout'], $options['persistent_id'], $options['retry_interval'], $options['read_timeout']);
97+
98+
if (\extension_loaded('redis') && version_compare(phpversion('redis'), '6.0.0', '>=')) {
99+
$params = [
100+
'host' => $host,
101+
'port' => $port,
102+
'connectTimeout' => $options['timeout'],
103+
'persistent' => $options['persistent_id'],
104+
'retryInterval' => $options['retry_interval'],
105+
'readTimeout' => $options['read_timeout'],
106+
];
107+
108+
$sentinelClient = new \RedisSentinel($params);
109+
} else {
110+
$sentinelClient = new $sentinelClass($host, $port, $options['timeout'], $options['persistent_id'], $options['retry_interval'], $options['read_timeout']);
111+
}
98112

99113
if (!$address = $sentinelClient->getMasterAddrByName($sentinelMaster)) {
100114
throw new InvalidArgumentException(sprintf('Failed to retrieve master information from master name "%s" and address "%s:%d".', $sentinelMaster, $host, $port));

0 commit comments

Comments
 (0)