Fix RateLimit when cache is disabled

This commit is contained in:
slawkens 2024-09-19 21:25:54 +02:00
parent 95a7c23a70
commit c6cc84a668

View File

@ -76,7 +76,7 @@ class RateLimit
public function save(): void public function save(): void
{ {
global $cache; global $cache;
if (!$this->enabled) { if (!$this->enabled || !$cache->enabled()) {
return; return;
} }
@ -92,7 +92,7 @@ class RateLimit
} }
$data = []; $data = [];
if ($this->enabled && $cache->enabled()) { if ($cache->enabled()) {
$tmp = ''; $tmp = '';
if ($cache->fetch($this->key, $tmp)) { if ($cache->fetch($this->key, $tmp)) {
$data = unserialize($tmp); $data = unserialize($tmp);
@ -110,8 +110,6 @@ class RateLimit
$this->save(); $this->save();
} }
} else {
$data = [];
} }
} }