Skip to content

Commit

Permalink
Avoid undefined array key 0 error (#40571)
Browse files Browse the repository at this point in the history
  • Loading branch information
tillkruss authored Jan 24, 2022
1 parent 60d60b0 commit 4bffc87
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function flushdb()
{
$arguments = func_get_args();

$async = strtoupper((string) $arguments[0] ?? null) === 'ASYNC';
$async = strtoupper((string) ($arguments[0] ?? null)) === 'ASYNC';

foreach ($this->client->_masters() as $master) {
$async
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Redis/Connections/PhpRedisConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ public function flushdb()
{
$arguments = func_get_args();

if (strtoupper((string) $arguments[0] ?? null) === 'ASYNC') {
if (strtoupper((string) ($arguments[0] ?? null)) === 'ASYNC') {
return $this->command('flushdb', [true]);
}

Expand Down
22 changes: 22 additions & 0 deletions tests/Redis/RedisConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,28 @@ public function testItGetsMultipleKeys()
}
}

public function testItFlushes()
{
foreach ($this->connections() as $redis) {
$redis->set('name', 'Till');
$this->assertSame(1, $redis->exists('name'));

$redis->flushdb();
$this->assertSame(0, $redis->exists('name'));
}
}

public function testItFlushesAsynchronous()
{
foreach ($this->connections() as $redis) {
$redis->set('name', 'Till');
$this->assertSame(1, $redis->exists('name'));

$redis->flushdb('ASYNC');
$this->assertSame(0, $redis->exists('name'));
}
}

public function testItRunsEval()
{
foreach ($this->connections() as $redis) {
Expand Down

0 comments on commit 4bffc87

Please sign in to comment.