Skip to content

Commit aa5ca01

Browse files
bug #39967 [Messenger] fix redis messenger options with dsn (Kleinast)
This PR was submitted for the 5.1 branch but it was merged into the 4.4 branch instead. Discussion ---------- [Messenger] fix redis messenger options with dsn | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #39834 | License | MIT This will fix the fact that you can use framework.messenger.transports.*.options to complete/default your redis configuration Commits ------- a0e7bf4 fix redis messenger options with dsn
2 parents d244e79 + a0e7bf4 commit aa5ca01

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Symfony/Component/Messenger/Tests/Transport/RedisExt/ConnectionTest.php

+13
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,19 @@ public function testFromDsnWithQueryOptions()
8585
);
8686
}
8787

88+
public function testFromDsnWithMixDsnQueryOptions()
89+
{
90+
$this->assertEquals(
91+
Connection::fromDsn('redis://localhost/queue/group1?serializer=2', ['consumer' => 'specific-consumer']),
92+
Connection::fromDsn('redis://localhost/queue/group1/specific-consumer?serializer=2')
93+
);
94+
95+
$this->assertEquals(
96+
Connection::fromDsn('redis://localhost/queue/group1/consumer1', ['consumer' => 'specific-consumer']),
97+
Connection::fromDsn('redis://localhost/queue/group1/consumer1')
98+
);
99+
}
100+
88101
public function testKeepGettingPendingMessages()
89102
{
90103
$redis = $this->getMockBuilder(\Redis::class)->disableOriginalConstructor()->getMock();

src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ public static function fromDsn(string $dsn, array $redisOptions = [], \Redis $re
101101
];
102102

103103
if (isset($parsedUrl['query'])) {
104-
parse_str($parsedUrl['query'], $redisOptions);
104+
parse_str($parsedUrl['query'], $dsnOptions);
105+
$redisOptions = array_merge($redisOptions, $dsnOptions);
105106
}
106107

107108
$autoSetup = null;

0 commit comments

Comments
 (0)