From fd08d991fe073cce7aee254ebaf48c246c833225 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Wed, 16 Jun 2021 05:32:45 +0200 Subject: [PATCH] log errors storing persistance --- lib/Persistence/PurgeLimiter.php | 7 +++++-- lib/Persistence/ServerSalt.php | 4 +++- lib/Persistence/TrafficLimiter.php | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/Persistence/PurgeLimiter.php b/lib/Persistence/PurgeLimiter.php index 89d5d60..ef37770 100644 --- a/lib/Persistence/PurgeLimiter.php +++ b/lib/Persistence/PurgeLimiter.php @@ -73,7 +73,10 @@ class PurgeLimiter extends AbstractPersistence if ($pl + self::$_limit >= $now) { return false; } - self::$_store->setValue((string) $now, 'purge_limiter'); - return true; + $hasStored = self::$_store->setValue((string) $now, 'purge_limiter'); + if (!$hasStored) { + error_log('failed to store the purge limiter, skipping purge cycle to avoid getting stuck in a purge loop'); + } + return $hasStored; } } diff --git a/lib/Persistence/ServerSalt.php b/lib/Persistence/ServerSalt.php index 50e1cd6..1095498 100644 --- a/lib/Persistence/ServerSalt.php +++ b/lib/Persistence/ServerSalt.php @@ -65,7 +65,9 @@ class ServerSalt extends AbstractPersistence self::$_salt = $salt; } else { self::$_salt = self::generate(); - self::$_store->setValue(self::$_salt, 'salt'); + if (!self::$_store->setValue(self::$_salt, 'salt')) { + error_log('failed to store the server salt, delete tokens, traffic limiter and user icons won\'t work'); + } } return self::$_salt; } diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index 4f11ec7..9e896c1 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -172,7 +172,9 @@ class TrafficLimiter extends AbstractPersistence $tl = time(); $result = true; } - self::$_store->setValue((string) $tl, 'traffic_limiter', $hash); + if (!self::$_store->setValue((string) $tl, 'traffic_limiter', $hash)) { + error_log('failed to store the traffic limiter, it probably contains outdated information'); + } return $result; } }