Skip to content

Commit

Permalink
Fix invalid array access on popTailBlocking timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed May 16, 2020
1 parent 6303aeb commit 7ccde09
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/RedisList.php
Expand Up @@ -154,14 +154,14 @@ public function popTail(): Promise
/**
* @param int $timeout
*
* @return Promise<string>
* @return Promise<string|null>
*
* @link https://redis.io/commands/brpop
*/
public function popTailBlocking(int $timeout = 0): Promise
{
return $this->queryExecutor->execute(['brpop', $this->key, $timeout], static function ($response) {
return $response[1];
return $response[1] ?? null;
});
}

Expand All @@ -181,7 +181,7 @@ public function popTailPushHead(string $destination): Promise
* @param string $destination
* @param int $timeout
*
* @return Promise<string>
* @return Promise<string|null>
*
* @link https://redis.io/commands/brpoplpush
*/
Expand Down
2 changes: 2 additions & 0 deletions test/RedisListTest.php
Expand Up @@ -49,5 +49,7 @@ public function test(): \Generator
$this->assertSame('b', yield $list->popTailBlocking());

$this->assertNull(yield $this->redis->getList('nonexistent')->popHeadBlocking(1));
$this->assertNull(yield $this->redis->getList('nonexistent')->popTailBlocking(1));
$this->assertNull(yield $this->redis->getList('nonexistent')->popTailPushHeadBlocking('nonexistent', 1));
}
}

0 comments on commit 7ccde09

Please sign in to comment.