From dbba0865e820e3710f9d21e470acc19df7c9e484 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Fri, 17 Dec 2021 09:01:12 +0100 Subject: [PATCH] Removed caching from the settings helper as it may lead to unexpected behavior (if for example values get updated in another way). --- application/helpers/setting_helper.php | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/application/helpers/setting_helper.php b/application/helpers/setting_helper.php index 747c0906..547e4013 100644 --- a/application/helpers/setting_helper.php +++ b/application/helpers/setting_helper.php @@ -45,8 +45,6 @@ if ( ! function_exists('setting')) throw new InvalidArgumentException('The $key argument cannot be empty.'); } - $cache = config('settings'); - if (is_array($key)) { foreach ($key as $name => $value) @@ -62,22 +60,13 @@ if ( ! function_exists('setting')) } $CI->settings_model->save($setting); - - $cache[$name] = $value; } - config(['settings' => $cache]); - return NULL; } - if (empty($cache[$key])) - { - $setting = $CI->settings_model->query()->where('name', $key)->get()->row_array(); + $setting = $CI->settings_model->query()->where('name', $key)->get()->row_array(); - $cache[$key] = $setting['value'] ?? NULL; - } - - return $cache[$key] ?? $default; + return $setting['value'] ?? $default; } }