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
-------

a0e7bf4c0d fix redis messenger options with dsn
This commit is contained in:
Nicolas Grekas 2021-01-26 09:57:27 +01:00
commit aa5ca01ed0
2 changed files with 15 additions and 1 deletions

View File

@ -85,6 +85,19 @@ class ConnectionTest extends TestCase
);
}
public function testFromDsnWithMixDsnQueryOptions()
{
$this->assertEquals(
Connection::fromDsn('redis://localhost/queue/group1?serializer=2', ['consumer' => 'specific-consumer']),
Connection::fromDsn('redis://localhost/queue/group1/specific-consumer?serializer=2')
);
$this->assertEquals(
Connection::fromDsn('redis://localhost/queue/group1/consumer1', ['consumer' => 'specific-consumer']),
Connection::fromDsn('redis://localhost/queue/group1/consumer1')
);
}
public function testKeepGettingPendingMessages()
{
$redis = $this->getMockBuilder(\Redis::class)->disableOriginalConstructor()->getMock();

View File

@ -101,7 +101,8 @@ class Connection
];
if (isset($parsedUrl['query'])) {
parse_str($parsedUrl['query'], $redisOptions);
parse_str($parsedUrl['query'], $dsnOptions);
$redisOptions = array_merge($redisOptions, $dsnOptions);
}
$autoSetup = null;