Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 68b3b89

Browse filesBrowse files
Seldaekchalasr
authored andcommitted
[Messenger] Make sure redis transports are initialized correctly
1 parent b3333e5 commit 68b3b89
Copy full SHA for 68b3b89

File tree

2 files changed

+15
-1
lines changed
Filter options

2 files changed

+15
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Tests/Transport/RedisExt/ConnectionTest.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ public function testFromDsnWithOptions()
6262
);
6363
}
6464

65+
public function testFromDsnWithOptionsAndTrailingSlash()
66+
{
67+
$this->assertEquals(
68+
Connection::fromDsn('redis://localhost/', ['stream' => 'queue', 'group' => 'group1', 'consumer' => 'consumer1', 'auto_setup' => false, 'serializer' => 2]),
69+
Connection::fromDsn('redis://localhost/queue/group1/consumer1?serializer=2&auto_setup=0')
70+
);
71+
}
72+
6573
public function testFromDsnWithQueryOptions()
6674
{
6775
$this->assertEquals(

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ public function __construct(array $configuration, array $connectionCredentials =
6363
throw new InvalidArgumentException('Redis connection failed: '.$redis->getLastError());
6464
}
6565

66+
foreach (['stream', 'group', 'consumer'] as $key) {
67+
if (isset($configuration[$key]) && '' === $configuration[$key]) {
68+
throw new InvalidArgumentException(sprintf('"%s" should be configured, got an empty string.', $key));
69+
}
70+
}
71+
6672
$this->stream = $configuration['stream'] ?? self::DEFAULT_OPTIONS['stream'];
6773
$this->group = $configuration['group'] ?? self::DEFAULT_OPTIONS['group'];
6874
$this->consumer = $configuration['consumer'] ?? self::DEFAULT_OPTIONS['consumer'];
@@ -77,7 +83,7 @@ public static function fromDsn(string $dsn, array $redisOptions = [], \Redis $re
7783
throw new InvalidArgumentException(sprintf('The given Redis DSN "%s" is invalid.', $dsn));
7884
}
7985

80-
$pathParts = explode('/', $parsedUrl['path'] ?? '');
86+
$pathParts = explode('/', rtrim($parsedUrl['path'] ?? '', '/'));
8187

8288
$stream = $pathParts[1] ?? $redisOptions['stream'] ?? null;
8389
$group = $pathParts[2] ?? $redisOptions['group'] ?? null;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.