Skip to content

Commit acf563b

Browse files
committed
Fix redis db select
1 parent a6fc84f commit acf563b

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

src/Dashboards/Redis/RedisDashboard.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,13 @@ class RedisDashboard implements DashboardInterface {
2929

3030
private int $current_server;
3131

32-
private int $current_db;
33-
3432
public function __construct(Template $template) {
3533
$this->template = $template;
3634

3735
$servers = Config::get('redis');
3836
$server = Http::get('server', 'int');
3937

4038
$this->current_server = array_key_exists($server, $servers) ? $server : 0;
41-
$this->current_db = Http::get('db', 'int', $servers[$this->current_server]['database'] ?? 0);
4239
}
4340

4441
/**
@@ -99,7 +96,7 @@ private function connect(array $server): Redis {
9996
}
10097

10198
try {
102-
$redis->select($this->current_db);
99+
$redis->select(Http::get('db', 'int', $server['database'] ?? 0));
103100
} catch (Exception $e) {
104101
throw new DashboardException(
105102
sprintf('Could not select Redis database (%s:%s). Error: %s', $server['host'], $server['port'], $e->getMessage())

src/Dashboards/Redis/RedisTrait.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,11 @@ private function mainDashboard(Redis $redis): string {
244244

245245
$paginator = new Paginator($this->template, $keys, [['db', 's', 'pp'], ['p' => '']]);
246246

247+
$servers = Config::get('redis');
248+
247249
return $this->template->render('dashboards/redis/redis', [
248250
'databases' => $this->getDatabases($redis),
249-
'current_db' => $this->current_db,
251+
'current_db' => Http::get('db', 'int', $servers[$this->current_server]['database'] ?? 0),
250252
'keys' => $paginator->getPaginated(),
251253
'all_keys' => $redis->dbSize(),
252254
'new_key_url' => Http::queryString(['db'], ['form' => 'new']),

0 commit comments

Comments
 (0)