Skip to content

Commit 4bffc87

Browse files
authored
Avoid undefined array key 0 error (#40571)
1 parent 60d60b0 commit 4bffc87

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

src/Illuminate/Redis/Connections/PhpRedisClusterConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function flushdb()
1313
{
1414
$arguments = func_get_args();
1515

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

1818
foreach ($this->client->_masters() as $master) {
1919
$async

src/Illuminate/Redis/Connections/PhpRedisConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ public function flushdb()
500500
{
501501
$arguments = func_get_args();
502502

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

tests/Redis/RedisConnectionTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,28 @@ public function testItGetsMultipleKeys()
467467
}
468468
}
469469

470+
public function testItFlushes()
471+
{
472+
foreach ($this->connections() as $redis) {
473+
$redis->set('name', 'Till');
474+
$this->assertSame(1, $redis->exists('name'));
475+
476+
$redis->flushdb();
477+
$this->assertSame(0, $redis->exists('name'));
478+
}
479+
}
480+
481+
public function testItFlushesAsynchronous()
482+
{
483+
foreach ($this->connections() as $redis) {
484+
$redis->set('name', 'Till');
485+
$this->assertSame(1, $redis->exists('name'));
486+
487+
$redis->flushdb('ASYNC');
488+
$this->assertSame(0, $redis->exists('name'));
489+
}
490+
}
491+
470492
public function testItRunsEval()
471493
{
472494
foreach ($this->connections() as $redis) {

0 commit comments

Comments
 (0)