8000 bug #43484 [Messenger] Fix Redis Transport when username is empty (vi… · symfony/symfony@20ad4e6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 20ad4e6

Browse files
committed
bug #43484 [Messenger] Fix Redis Transport when username is empty (villfa)
This PR was merged into the 4.4 branch. Discussion ---------- [Messenger] Fix Redis Transport when username is empty | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #43306 | License | MIT | Doc PR | n/a Checking the username and the password with `isset` is not enough. We also need to check they're not empty strings. This fixes the BC break introduced by #43124. See also https://3v4l.org/iASnE Commits ------- cd66b8c [Messenger] Fix Redis Transport when username is empty
2 parents 5eef649 + cd66b8c commit 20ad4e6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ public function provideAuthDsn(): \Generator
133133
{
134134
yield 'Password only' => ['password', 'redis://password@localhost/queue'];
135135
yield 'User and password' => [['user', 'password'], 'redis://user:password@localhost/queue'];
136+
yield 'User and colon' => ['user', 'redis://user:@localhost/queue'];
137+
yield 'Colon and password' => ['password', 'redis://:password@localhost/queue'];
138+
yield 'Colon and falsy password' => ['0', 'redis://:0@localhost/queue'];
136139
}
137140

138141
public function testNoAuthWithEmptyPassword()

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,14 @@ public static function fromDsn(string $dsn, array $redisOptions = [], \Redis $re
9393
$stream = $pathParts[1] ?? $redisOptions['stream'] ?? null;
9494
$group = $pathParts[2] ?? $redisOptions['group'] ?? null;
9595
$consumer = $pathParts[3] ?? $redisOptions['consumer'] ?? null;
96+
$pass = '' !== ($parsedUrl['pass'] ?? '') ? $parsedUrl['pass'] : null;
97+
$user = '' !== ($parsedUrl['user'] ?? '') ? $parsedUrl['user'] : null;
9698

9799
$connectionCredentials = [
98100
'host' => $parsedUrl['host'] ?? '127.0.0.1',
99101
'port' => $parsedUrl['port'] ?? 6379,
100102
// See: https://github.com/phpredis/phpredis/#auth
101-
'auth' => isset($parsedUrl['pass']) && isset($parsedUrl['user']) ? [$parsedUrl['user'], $parsedUrl['pass']] : $parsedUrl['pass'] ?? $parsedUrl['user'] ?? null,
103+
'auth' => null !== $pass && null !== $user ? [$user, $pass] : ($pass ?? $user),
102104
];
103105

104106
if (isset($parsedUrl['query'])) {

0 commit comments

Comments
 (0)
0