update clear cache method for settings object

This commit is contained in:
Tim Fry 2025-03-31 09:46:48 -03:00
parent efd9f8979e
commit 92023260dc
1 changed files with 9 additions and 0 deletions

View File

@ -450,12 +450,21 @@ class settings implements clear_cache {
if (function_exists('apcu_enabled') && apcu_enabled()) {
$cache = apcu_cache_info(false);
if (!empty($cache['cache_list'])) {
//clear apcu cache
foreach ($cache['cache_list'] as $entry) {
$key = $entry['info'];
if (str_starts_with($key, 'settings_')) {
apcu_delete($key);
}
}
global $settings, $domain_uuid, $user_uuid;
//check there is a settings object
if (!empty($settings) && ($settings instanceof settings)) {
$domain_uuid = $settings->get_domain_uuid();
$user_uuid = $settings->get_user_uuid();
//recreate the settings object to reload all settings from database
$settings = new settings(['database' => database::new(), 'domain_uuid' => $domain_uuid, 'user_uuid' => $user_uuid]);
}
}
}
}