Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8c56020

Browse files
committed
bug #52896 [Messenger] Avoid reconnecting active Redis connections. (BusterNeece)
This PR was merged into the 5.4 branch. Discussion ---------- [Messenger] Avoid reconnecting active Redis connections. | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #45057 | License | MIT With the Messenger component's internal Redis Connection class, if you pass it a \Redis or \Relay instance that's already connected, it will still try to reconnect that instance using the host/port/etc. that's passed to the connection object's "options" array in the constructor. Not only does this cause problems when the Redis instance is already connected, but it also prevents you from, say, using socket connections instead (as the only connection method supported by the class itself is IP-based connections) and just passing in a ready-to-go Redis instance. This PR is a resubmission of #52811 targeting 5.4 as it's a bug fix. Commits ------- 650f153 bug #45057 [Messenger] Avoid reconnecting active Redis connections.
2 parents a3361bd + 650f153 commit 8c56020

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ public function __construct(array $configuration, array $connectionCredentials =
117117
*/
118118
private static function initializeRedis(\Redis $redis, string $host, int $port, $auth, int $serializer, int $dbIndex): \Redis
119119
{
120+
if ($redis->isConnected()) {
121+
return $redis;
122+
}
123+
120124
$redis->connect($host, $port);
121125
$redis->setOption(\Redis::OPT_SERIALIZER, $serializer);
122126

0 commit comments

Comments
 (0)