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

fd8d6b8187 [Messenger] Fix undefined index on read timeout
This commit is contained in:
Fabien Potencier 2019-05-19 21:00:29 +02:00
commit abefb53d7c
2 changed files with 18 additions and 2 deletions

View File

@ -115,7 +115,8 @@ class ConnectionTest extends TestCase
public function testGetAfterReject()
{
$connection = Connection::fromDsn('redis://localhost/messenger-rejectthenget');
$redis = new \Redis();
$connection = Connection::fromDsn('redis://localhost/messenger-rejectthenget', [], $redis);
try {
$connection->setup();
} catch (TransportException $e) {
@ -129,5 +130,20 @@ class ConnectionTest extends TestCase
$connection = Connection::fromDsn('redis://localhost/messenger-rejectthenget');
$this->assertNotNull($connection->get());
$redis->del('messenger-rejectthenget');
}
public function testBlockingTimeout()
{
$redis = new \Redis();
$connection = Connection::fromDsn('redis://localhost/messenger-blockingtimeout', ['blocking_timeout' => 1], $redis);
try {
$connection->setup();
} catch (TransportException $e) {
}
$this->assertNull($connection->get());
$redis->del('messenger-blockingtimeout');
}
}

View File

@ -102,7 +102,7 @@ class Connection
return $this->get();
}
foreach ($messages[$this->stream] as $key => $message) {
foreach ($messages[$this->stream] ?? [] as $key => $message) {
$redisEnvelope = \json_decode($message['message'], true);
return [