Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Avoid undefined array key 0 error #40571

Merged
merged 1 commit into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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