From b3e4463ace0f487008af2b1b3f324bf12c40cf72 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 6 Mar 2020 13:47:19 +1300 Subject: [PATCH] Add some deprecation notices, stop calling PrevNext::cleanupCache --- CRM/Core/BAO/Cache.php | 2 +- CRM/Core/BAO/PrevNextCache.php | 10 ++++++++++ CRM/Utils/Cache/SqlGroup.php | 3 +-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CRM/Core/BAO/Cache.php b/CRM/Core/BAO/Cache.php index 9c14476c94..ee678348dd 100644 --- a/CRM/Core/BAO/Cache.php +++ b/CRM/Core/BAO/Cache.php @@ -387,7 +387,7 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache { if ($prevNext) { // delete all PrevNext caches - CRM_Core_BAO_PrevNextCache::cleanupCache(); + Civi::service('prevnext')->cleanup(); } if ($table) { diff --git a/CRM/Core/BAO/PrevNextCache.php b/CRM/Core/BAO/PrevNextCache.php index ca53363abf..4eae51e91a 100644 --- a/CRM/Core/BAO/PrevNextCache.php +++ b/CRM/Core/BAO/PrevNextCache.php @@ -326,6 +326,7 @@ FROM civicrm_prevnext_cache pn * @return array */ public static function convertSetItemValues($sqlValues) { + CRM_Core_Error::deprecatedFunctionWarning('Deprecated function'); $closingBrace = strpos($sqlValues, ')') - strlen($sqlValues); $valueArray = array_map('trim', explode(', ', substr($sqlValues, strpos($sqlValues, '(') + 1, $closingBrace - 1))); foreach ($valueArray as $key => &$value) { @@ -462,7 +463,13 @@ WHERE (pn.cachekey $op %1 OR pn.cachekey $op %2) } } + /** + * Old function to clean up he cache. + * + * @deprecated. + */ public static function cleanupCache() { + CRM_Core_Error::deprecatedFunctionWarning('Deprecated function'); Civi::service('prevnext')->cleanup(); } @@ -476,6 +483,7 @@ WHERE (pn.cachekey $op %1 OR pn.cachekey $op %2) * @see CRM_Core_PrevNextCache_Sql::getSelection() */ public static function getSelection($cacheKey, $action = 'get') { + CRM_Core_Error::deprecatedFunctionWarning('Deprecated function'); return Civi::service('prevnext')->getSelection($cacheKey, $action); } @@ -533,6 +541,8 @@ WHERE (pn.cachekey $op %1 OR pn.cachekey $op %2) * @param array $fieldDef * @param int $counter * The globally-unique ID of the test object. + * + * @throws \CRM_Core_Exception */ protected function assignTestValue($fieldName, &$fieldDef, $counter) { if ($fieldName === 'cachekey') { diff --git a/CRM/Utils/Cache/SqlGroup.php b/CRM/Utils/Cache/SqlGroup.php index 3aa8bb17c0..3f499aa930 100644 --- a/CRM/Utils/Cache/SqlGroup.php +++ b/CRM/Utils/Cache/SqlGroup.php @@ -211,8 +211,7 @@ class CRM_Utils_Cache_SqlGroup implements CRM_Utils_Cache_Interface { public function flush() { if ($this->group == CRM_Utils_Cache::cleanKey('CiviCRM Search PrevNextCache') && Civi::service('prevnext') instanceof CRM_Core_PrevNextCache_Sql) { - // Use the standard PrevNextCache cleanup function here not just delete from civicrm_cache - CRM_Core_BAO_PrevNextCache::cleanupCache(); + Civi::service('prevnext')->cleanup(); } else { CRM_Core_DAO::executeQuery("DELETE FROM {$this->table} WHERE {$this->where()}"); -- 2.25.1