Skip to content

Commit 43a1fa1

Browse files
bug #52629 [Messenger] Fix support for Redis Sentinel using php-redis 6.0.0 (pepeh)
This PR was squashed before being merged into the 6.3 branch. Discussion ---------- [Messenger] Fix support for Redis Sentinel using php-redis 6.0.0 | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #52487 | License | MIT Added support for [php-redis 6.0.0](https://github.com/phpredis/phpredis/blob/develop/CHANGELOG.md#600---2023-09-09-github-pecl) to Symfony/Component/Messenger/Bridge/Redis/Transport/Connection. A similar fix was done for RedisTrait before: #51683 Commits ------- 42a80db [Messenger] Fix support for Redis Sentinel using php-redis 6.0.0
2 parents d546ade + 42a80db commit 43a1fa1

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

Lines changed: 15 additions & 1 deletion
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)
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