Skip to content

Commit 1b0aed0

Browse files
bug #51775 [Cache] Fix two initializations of Redis Sentinel (digilist)
This PR was merged into the 6.4 branch. Discussion ---------- [Cache] Fix two initializations of Redis Sentinel | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | n/a | License | MIT After #51687 and #51683 have been merged, there are now two initializations of Redis Sentinel, which also leads to the integration test failure mentioned in [this comment](#51687 (comment)). This PR fixes this. Commits ------- 2d23a1b [Cache] Fix two initializations of Redis Sentinel
2 parents 3c4cfbd + 2d23a1b commit 1b0aed0

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

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

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -223,29 +223,28 @@ public static function createConnection(#[\SensitiveParameter] string $dsn, arra
223223
break;
224224
}
225225

226-
if (version_compare(phpversion('redis'), '6.0.0', '>=') && $isRedisExt) {
227-
$options = [
228-
'host' => $host,
229-
'port' => $port,
230-
'connectTimeout' => $params['timeout'],
231-
'persistent' => $params['persistent_id'],
232-
'retryInterval' => $params['retry_interval'],
233-
'readTimeout' => $params['read_timeout'],
234-
];
235-
236-
if ($passAuth) {
237-
$options['auth'] = $params['auth'];
226+
try {
227+
if (version_compare(phpversion('redis'), '6.0.0', '>=') && $isRedisExt) {
228+
$options = [
229+
'host' => $host,
230+
'port' => $port,
231+
'connectTimeout' => $params['timeout'],
232+
'persistent' => $params['persistent_id'],
233+
'retryInterval' => $params['retry_interval'],
234+
'readTimeout' => $params['read_timeout'],
235+
];
236+
237+
if ($passAuth) {
238+
$options['auth'] = $params['auth'];
239+
}
240+
241+
$sentinel = new \RedisSentinel($options);
242+
} else {
243+
$extra = $passAuth ? [$params['auth']] : [];
244+
245+
$sentinel = new $sentinelClass($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout'], ...$extra);
238246
}
239247

240-
$sentinel = new \RedisSentinel($options);
241-
} else {
242-
$extra = $passAuth ? [$params['auth']] : [];
243-
244-
$sentinel = new $sentinelClass($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout'], ...$extra);
245-
}
246-
247-
try {
248-
$sentinel = new $sentinelClass($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout'], ...$extra);
249248
if ($address = $sentinel->getMasterAddrByName($params['redis_sentinel'])) {
250249
[$host, $port] = $address;
251250
}

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