8000 bug #31544 [Messenger] Fix undefined index on read timeout (chalasr) · symfony/symfony@abefb53 · GitHub
[go: up one dir, main page]

Skip to content

Commit abefb53

Browse files
committed
bug #31544 [Messenger] Fix undefined index on read timeout (chalasr)
This PR was merged into the 4.3 branch. Discussion ---------- [Messenger] Fix undefined index on read timeout | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Commits ------- fd8d6b8 [Messenger] Fix undefined index on read timeout
2 parents e606ac1 + fd8d6b8 commit abefb53

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ public function testUnexpectedRedisError()
115115

116116
public function testGetAfterReject()
117117
{
118-
$connection = Connection::fromDsn('redis://localhost/messenger-rejectthenget');
118+
$redis = new \Redis();
119+
$connection = Connection::fromDsn('redis://localhost/messenger-rejectthenget', [], $redis);
119120
try {
120121
$connection->setup();
121122
} catch (TransportException $e) {
@@ -129,5 +130,20 @@ public function testGetAfterReject()
129130

130131
$connection = Connection::fromDsn('redis://localhost/messenger-rejectthenget');
131132
$this->assertNotNull($connection->get());
133+
134+
$redis->del('messenger-rejectthenget');
135+
}
136+
137+
public function testBlockingTimeout()
138+
{
139+
$redis = new \Redis();
140+
$connection = Connection::fromDsn('redis://localhost/messenger-blockingtimeout', ['blocking_timeout' => 1], $redis);
141+
try {
142+
$connection->setup();
143+
} catch (TransportException $e) {
144+
}
145+
146+
$this->assertNull($connection->get());
147+
$redis->del('messenger-blockingtimeout');
132148
}
133149
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function get(): ?array
102102
return $this->get();
103103
}
104104

105-
foreach ($messages[$this->stream] as $key => $message) {
105+
foreach ($messages[$this->stream] ?? [] as $key => $message) {
106106
$redisEnvelope = \json_decode($message['message'], true);
107107

108108
return [

0 commit comments

Comments
 (0)
0