From: Seamus Lee Date: Tue, 18 Jun 2019 22:46:06 +0000 (+1000) Subject: Convert the contact fields cache group to standard cache backend X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9cdf85c1d99c32d7b20023920cc4df4af555550f;p=civicrm-core.git Convert the contact fields cache group to standard cache backend --- diff --git a/CRM/ACL/BAO/ACL.php b/CRM/ACL/BAO/ACL.php index abf87247bb..bc823b9703 100644 --- a/CRM/ACL/BAO/ACL.php +++ b/CRM/ACL/BAO/ACL.php @@ -688,7 +688,7 @@ SELECT $acl.* */ public static function setIsActive($id, $is_active) { // note this also resets any ACL cache - CRM_Core_BAO_Cache::deleteGroup('contact fields'); + Civi::cache('fields')->flush(); return CRM_Core_DAO::setFieldValue('CRM_ACL_DAO_ACL', $id, 'is_active', $is_active); } diff --git a/CRM/ACL/Form/ACL.php b/CRM/ACL/Form/ACL.php index b119f7503a..b0824e56b2 100644 --- a/CRM/ACL/Form/ACL.php +++ b/CRM/ACL/Form/ACL.php @@ -254,7 +254,7 @@ class CRM_ACL_Form_ACL extends CRM_Admin_Form { */ public function postProcess() { // note this also resets any ACL cache - CRM_Core_BAO_Cache::deleteGroup('contact fields'); + Civi::cache('fields')->flush(); if ($this->_action & CRM_Core_Action::DELETE) { CRM_ACL_BAO_ACL::del($this->_id); diff --git a/CRM/Admin/Form/Setting/Localization.php b/CRM/Admin/Form/Setting/Localization.php index e5c52cd7c3..2e85c5924a 100644 --- a/CRM/Admin/Form/Setting/Localization.php +++ b/CRM/Admin/Form/Setting/Localization.php @@ -184,7 +184,7 @@ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting { //cache contact fields retaining localized titles //though we changed localization, so reseting cache. - CRM_Core_BAO_Cache::deleteGroup('contact fields'); + Civi::cache('fields')->flush(); //CRM-8559, cache navigation do not respect locale if it is changed, so reseting cache. Civi::cache('navigation')->flush(); diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index bd56e2127e..fce78b7aff 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -1351,12 +1351,7 @@ WHERE civicrm_contact.id = " . CRM_Utils_Type::escape($id, 'Integer'); $cacheKeyString .= $checkPermission ? '_1' : '_0'; $cacheKeyString .= '_' . CRM_Core_Config::domainID() . '_'; - $fields = CRM_Utils_Array::value($cacheKeyString, self::$_importableFields); - - if (!$fields) { - // check if we can retrieve from database cache - $fields = CRM_Core_BAO_Cache::getItem('contact fields', $cacheKeyString); - } + $fields = CRM_Utils_Array::value($cacheKeyString, self::$_importableFields) ?: Civi::cache('fields')->get($cacheKeyString); if (!$fields) { $fields = CRM_Contact_DAO_Contact::import(); @@ -1494,7 +1489,7 @@ WHERE civicrm_contact.id = " . CRM_Utils_Type::escape($id, 'Integer'); //Sorting fields in alphabetical order(CRM-1507) $fields = CRM_Utils_Array::crmArraySortByField($fields, 'title'); - CRM_Core_BAO_Cache::setItem($fields, 'contact fields', $cacheKeyString); + Civi::cache('fields')->set($cacheKeyString, $fields); } self::$_importableFields[$cacheKeyString] = $fields; @@ -1552,7 +1547,7 @@ WHERE civicrm_contact.id = " . CRM_Utils_Type::escape($id, 'Integer'); } // check if we can retrieve from database cache - $fields = CRM_Core_BAO_Cache::getItem('contact fields', $cacheKeyString); + $fields = Civi::cache('fields')->get($cacheKeyString); if (!$fields) { $fields = CRM_Contact_DAO_Contact::export(); @@ -1742,7 +1737,7 @@ WHERE civicrm_contact.id = " . CRM_Utils_Type::escape($id, 'Integer'); } } - CRM_Core_BAO_Cache::setItem($fields, 'contact fields', $cacheKeyString); + Civi::cache('fields')->set($cacheKeyString, $fields); } self::$_exportableFields[$cacheKeyString] = $fields; } diff --git a/CRM/Core/BAO/Cache/Psr16.php b/CRM/Core/BAO/Cache/Psr16.php index 384629af94..b4f7241957 100644 --- a/CRM/Core/BAO/Cache/Psr16.php +++ b/CRM/Core/BAO/Cache/Psr16.php @@ -181,9 +181,6 @@ class CRM_Core_BAO_Cache_Psr16 { */ public static function getLegacyGroups() { $groups = [ - // Core - 'contact fields', - // Universe // be.chiro.civi.atomfeeds diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index f6dce2967d..6b704a2d85 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -401,7 +401,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { } // check if we can retrieve from database cache - $fields = CRM_Core_BAO_Cache::getItem('contact fields', "custom importableFields $cacheKey"); + $fields = Civi::Cache('fields')->get("custom importableFields $cacheKey"); if ($fields === NULL) { $cfTable = self::getTableName(); @@ -547,10 +547,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { } - CRM_Core_BAO_Cache::setItem($fields, - 'contact fields', - "custom importableFields $cacheKey" - ); + Civi::cache('fields')->set("custom importableFields $cacheKey", $fields); } self::$_importFields[$cacheKey] = $fields; } diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index 036338d853..b4da3671a1 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -259,7 +259,7 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { */ public static function setIsActive($id, $is_active) { // reset the cache - CRM_Core_BAO_Cache::deleteGroup('contact fields'); + Civi::cache('fields')->flush(); if (!$is_active) { CRM_Core_BAO_UFField::setUFFieldStatus($id, $is_active); diff --git a/CRM/Custom/Form/ChangeFieldType.php b/CRM/Custom/Form/ChangeFieldType.php index 7e89f12382..eb079dff19 100644 --- a/CRM/Custom/Form/ChangeFieldType.php +++ b/CRM/Custom/Form/ChangeFieldType.php @@ -187,7 +187,7 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form { $customField->save(); // Reset cache for custom fields - CRM_Core_BAO_Cache::deleteGroup('contact fields'); + Civi::cache('fields')->flush(); CRM_Core_Session::setStatus(ts('Input type of custom field \'%1\' has been successfully changed to \'%2\'.', [1 => $this->_values['label'], 2 => $dstHtmlType] diff --git a/CRM/Custom/Form/Field.php b/CRM/Custom/Form/Field.php index 14d407950a..3ca131b873 100644 --- a/CRM/Custom/Form/Field.php +++ b/CRM/Custom/Form/Field.php @@ -1019,7 +1019,7 @@ SELECT id $this->_id = $customField->id; // reset the cache - CRM_Core_BAO_Cache::deleteGroup('contact fields'); + Civi::cache('fields')->flush(); $msg = '

' . ts("Custom field '%1' has been saved.", [1 => $customField->label]) . '

'; diff --git a/CRM/Custom/Form/Group.php b/CRM/Custom/Form/Group.php index d57e422557..bdc2929402 100644 --- a/CRM/Custom/Form/Group.php +++ b/CRM/Custom/Form/Group.php @@ -457,7 +457,7 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { $group = CRM_Core_BAO_CustomGroup::create($params); // reset the cache - CRM_Core_BAO_Cache::deleteGroup('contact fields'); + Civi::cache('fields')->flush(); if ($this->_action & CRM_Core_Action::UPDATE) { CRM_Core_Session::setStatus(ts('Your custom field set \'%1 \' has been saved.', [1 => $group->title]), ts('Saved'), 'success'); diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index fcdb2a1f66..622e1aae9a 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -1449,7 +1449,7 @@ class CRM_Utils_System { // also reset the various static memory caches // reset the memory or array cache - CRM_Core_BAO_Cache::deleteGroup('contact fields', NULL, FALSE); + Civi::cache('fields')->flush(); // reset ACL cache CRM_ACL_BAO_Cache::resetCache(); diff --git a/Civi/Core/Container.php b/Civi/Core/Container.php index c456d3d0d8..9ff7617118 100644 --- a/Civi/Core/Container.php +++ b/Civi/Core/Container.php @@ -159,6 +159,7 @@ class Container { 'groups' => 'contact groups', 'navigation' => 'navigation', 'customData' => 'custom data', + 'fields' => 'contact fields', ]; foreach ($basicCaches as $cacheSvc => $cacheGrp) { $definitionParams = [