From 1f2dddd9d85c3feb0dd4c210a41bc369252de3c1 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 13 Jun 2021 10:53:01 +0200 Subject: [PATCH] address Codacy issues --- lib/Data/AbstractData.php | 8 ++++---- lib/Data/Database.php | 12 ++++++------ lib/Data/Filesystem.php | 10 +++++----- lib/Persistence/ServerSalt.php | 9 --------- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/lib/Data/AbstractData.php b/lib/Data/AbstractData.php index 6f2dee53..52a85a41 100644 --- a/lib/Data/AbstractData.php +++ b/lib/Data/AbstractData.php @@ -35,7 +35,7 @@ abstract class AbstractData * @static * @var array */ - protected static $_traffic_limiter_cache = array(); + protected static $_last_cache = array(); /** * Enforce singleton, disable constructor @@ -150,9 +150,9 @@ abstract class AbstractData public function purgeValues($namespace, $time) { if ($namespace === 'traffic_limiter') { - foreach (self::$_traffic_limiter_cache as $key => $last_access) { - if ($last_access <= $time) { - unset(self::$_traffic_limiter_cache[$key]); + foreach (self::$_last_cache as $key => $last_submission) { + if ($last_submission <= $time) { + unset(self::$_last_cache[$key]); } } } diff --git a/lib/Data/Database.php b/lib/Data/Database.php index a15b8621..dea1be6d 100644 --- a/lib/Data/Database.php +++ b/lib/Data/Database.php @@ -447,9 +447,9 @@ class Database extends AbstractData public function setValue($value, $namespace, $key = '') { if ($namespace === 'traffic_limiter') { - self::$_traffic_limiter_cache[$key] = $value; + self::$_last_cache[$key] = $value; try { - $value = Json::encode(self::$_traffic_limiter_cache); + $value = Json::encode(self::$_last_cache); } catch (Exception $e) { return false; } @@ -492,12 +492,12 @@ class Database extends AbstractData } if ($value && $namespace === 'traffic_limiter') { try { - self::$_traffic_limiter_cache = Json::decode($value); + self::$_last_cache = Json::decode($value); } catch (Exception $e) { - self::$_traffic_limiter_cache = array(); + self::$_last_cache = array(); } - if (array_key_exists($key, self::$_traffic_limiter_cache)) { - return self::$_traffic_limiter_cache[$key]; + if (array_key_exists($key, self::$_last_cache)) { + return self::$_last_cache[$key]; } } return (string) $value; diff --git a/lib/Data/Filesystem.php b/lib/Data/Filesystem.php index 384c72d1..9b8e7ba5 100644 --- a/lib/Data/Filesystem.php +++ b/lib/Data/Filesystem.php @@ -263,10 +263,10 @@ class Filesystem extends AbstractData '