Update clear cache method for settings object (#7348)
* update clear cache method for settings object * re-use the database object from settings object
This commit is contained in:
parent
7d51c8cdd5
commit
5c1be1a318
|
|
@ -450,12 +450,22 @@ class settings implements clear_cache {
|
||||||
if (function_exists('apcu_enabled') && apcu_enabled()) {
|
if (function_exists('apcu_enabled') && apcu_enabled()) {
|
||||||
$cache = apcu_cache_info(false);
|
$cache = apcu_cache_info(false);
|
||||||
if (!empty($cache['cache_list'])) {
|
if (!empty($cache['cache_list'])) {
|
||||||
|
//clear apcu cache
|
||||||
foreach ($cache['cache_list'] as $entry) {
|
foreach ($cache['cache_list'] as $entry) {
|
||||||
$key = $entry['info'];
|
$key = $entry['info'];
|
||||||
if (str_starts_with($key, 'settings_')) {
|
if (str_starts_with($key, 'settings_')) {
|
||||||
apcu_delete($key);
|
apcu_delete($key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
global $settings;
|
||||||
|
//check there is a settings object
|
||||||
|
if (!empty($settings) && ($settings instanceof settings)) {
|
||||||
|
$database = $settings->database();
|
||||||
|
$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, 'domain_uuid' => $domain_uuid, 'user_uuid' => $user_uuid]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue