Commit 96689db3 authored by Seamus Lee's avatar Seamus Lee

Convert Navigation cache group to current cache defition system

Also reset memory and system caches when resetting navigation

Additonal place to cause extra flush

Add in utility function for resetting ACL and System Level Caches

Use cache utility function
parent e38990f9
...@@ -187,7 +187,9 @@ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting { ...@@ -187,7 +187,9 @@ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting {
CRM_Core_BAO_Cache::deleteGroup('contact fields'); CRM_Core_BAO_Cache::deleteGroup('contact fields');
//CRM-8559, cache navigation do not respect locale if it is changed, so reseting cache. //CRM-8559, cache navigation do not respect locale if it is changed, so reseting cache.
CRM_Core_BAO_Cache::deleteGroup('navigation'); Civi::cache('navigation')->flush();
// reset ACL and System caches
CRM_Core_BAO_Cache::resetCaches();
// we do this only to initialize monetary decimal point and thousand separator // we do this only to initialize monetary decimal point and thousand separator
$config = CRM_Core_Config::singleton(); $config = CRM_Core_Config::singleton();
......
...@@ -183,7 +183,6 @@ class CRM_Core_BAO_Cache_Psr16 { ...@@ -183,7 +183,6 @@ class CRM_Core_BAO_Cache_Psr16 {
$groups = [ $groups = [
// Core // Core
'contact fields', 'contact fields',
'navigation',
'custom data', 'custom data',
// Universe // Universe
......
...@@ -156,7 +156,7 @@ class CRM_Core_BAO_ConfigSetting { ...@@ -156,7 +156,7 @@ class CRM_Core_BAO_ConfigSetting {
//CRM-8559, cache navigation do not respect locale if it is changed, so reseting cache. //CRM-8559, cache navigation do not respect locale if it is changed, so reseting cache.
// Ed: This doesn't sound good. // Ed: This doesn't sound good.
// CRM_Core_BAO_Cache::deleteGroup('navigation'); // Civi::cache('navigation')->flush();
} }
else { else {
$requestLocale = NULL; $requestLocale = NULL;
......
...@@ -165,7 +165,7 @@ class CRM_Core_BAO_Navigation extends CRM_Core_DAO_Navigation { ...@@ -165,7 +165,7 @@ class CRM_Core_BAO_Navigation extends CRM_Core_DAO_Navigation {
$config = CRM_Core_Config::singleton(); $config = CRM_Core_Config::singleton();
// check if we can retrieve from database cache // check if we can retrieve from database cache
$navigations = CRM_Core_BAO_Cache::getItem('navigation', $cacheKeyString); $navigations = Civi::cache('navigation')->get($cacheKeyString);
if (!$navigations) { if (!$navigations) {
$domainID = CRM_Core_Config::domainID(); $domainID = CRM_Core_Config::domainID();
...@@ -186,7 +186,7 @@ FROM civicrm_navigation WHERE domain_id = $domainID"; ...@@ -186,7 +186,7 @@ FROM civicrm_navigation WHERE domain_id = $domainID";
$navigations = []; $navigations = [];
self::_getNavigationLabel($pidGroups[''], $navigations); self::_getNavigationLabel($pidGroups[''], $navigations);
CRM_Core_BAO_Cache::setItem($navigations, 'navigation', $cacheKeyString); Civi::cache('navigation')->set($cacheKeyString, $navigations);
} }
return $navigations; return $navigations;
} }
...@@ -567,7 +567,9 @@ FROM civicrm_navigation WHERE domain_id = $domainID"; ...@@ -567,7 +567,9 @@ FROM civicrm_navigation WHERE domain_id = $domainID";
$ser = serialize($newKey); $ser = serialize($newKey);
$query = "UPDATE civicrm_setting SET value = '$ser' WHERE name='navigation' AND contact_id IS NOT NULL"; $query = "UPDATE civicrm_setting SET value = '$ser' WHERE name='navigation' AND contact_id IS NOT NULL";
CRM_Core_DAO::executeQuery($query); CRM_Core_DAO::executeQuery($query);
CRM_Core_BAO_Cache::deleteGroup('navigation'); Civi::cache('navigation')->flush();
// reset ACL and System caches
CRM_Core_BAO_Cache::resetCaches();
} }
else { else {
// before inserting check if contact id exists in db // before inserting check if contact id exists in db
......
...@@ -1440,6 +1440,7 @@ class CRM_Utils_System { ...@@ -1440,6 +1440,7 @@ class CRM_Utils_System {
Civi::cache('js_strings')->flush(); Civi::cache('js_strings')->flush();
Civi::cache('community_messages')->flush(); Civi::cache('community_messages')->flush();
Civi::cache('groups')->flush(); Civi::cache('groups')->flush();
Civi::cache('navigation')->flush();
CRM_Extension_System::singleton()->getCache()->flush(); CRM_Extension_System::singleton()->getCache()->flush();
CRM_Cxn_CiviCxnHttp::singleton()->getCache()->flush(); CRM_Cxn_CiviCxnHttp::singleton()->getCache()->flush();
} }
......
...@@ -157,6 +157,7 @@ class Container { ...@@ -157,6 +157,7 @@ class Container {
'session' => 'CiviCRM Session', 'session' => 'CiviCRM Session',
'long' => 'long', 'long' => 'long',
'groups' => 'contact groups', 'groups' => 'contact groups',
'navigation' => 'navigation',
]; ];
foreach ($basicCaches as $cacheSvc => $cacheGrp) { foreach ($basicCaches as $cacheSvc => $cacheGrp) {
$definitionParams = [ $definitionParams = [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment