Standardise exception use in test suite
[civicrm-core.git] / CRM / Core / BAO / Cache / Psr16.php
index 48ae52994d4e9abceed0f0fd904c084068eb5c37..b1de19199694dd1c85e2b8a49bf8907bb7a8effd 100644 (file)
@@ -62,7 +62,7 @@ class CRM_Core_BAO_Cache_Psr16 {
 
       $cache = CRM_Utils_Cache::create([
         'name' => "bao_$group",
-        'type' => array('*memory*', 'SqlGroup', 'ArrayCache'),
+        'type' => ['*memory*', 'SqlGroup', 'ArrayCache'],
         // We're replacing CRM_Core_BAO_Cache, which traditionally used a front-cache
         // that was not aware of TTLs. So it seems more consistent/performant to
         // use 'fast' here.
@@ -180,7 +180,7 @@ class CRM_Core_BAO_Cache_Psr16 {
    * @return array
    */
   public static function getLegacyGroups() {
-    return [
+    $groups = [
       // Core
       'CiviCRM Search PrevNextCache',
       'contact fields',
@@ -189,12 +189,34 @@ class CRM_Core_BAO_Cache_Psr16 {
       'custom data',
 
       // Universe
-      'dashboard', // be.chiro.civi.atomfeeds
-      'lineitem-editor', // biz.jmaconsulting.lineitemedit
-      'HRCore_Info', // civihr/uk.co.compucorp.civicrm.hrcore
-      'CiviCRM setting Spec', // nz.co.fuzion.entitysetting
-      'descendant groups for an org', // org.civicrm.multisite
+
+      // be.chiro.civi.atomfeeds
+      'dashboard',
+
+      // biz.jmaconsulting.lineitemedit
+      'lineitem-editor',
+
+      // civihr/uk.co.compucorp.civicrm.hrcore
+      'HRCore_Info',
+
+      // nz.co.fuzion.entitysetting
+      'CiviCRM setting Spec',
+
     ];
+    // Handle Legacy Multisite caching group.
+    $extensions = CRM_Extension_System::singleton()->getManager();
+    $multisiteExtensionStatus = $extensions->getStatus('org.civicrm.multisite');
+    if ($multisiteExtensionStatus == $extensions::STATUS_INSTALLED) {
+      $extension_version = civicrm_api3('Extension', 'get', ['key' => 'org.civicrm.multisite'])['values'][0]['version'];
+      if (version_compare($extension_version, '2.7', '<')) {
+        Civi::log()->warning(
+          'CRM_Core_BAO_Cache_PSR is deprecated for multisite extension, you should upgrade to the latest version to avoid this warning, this code will be removed at the end of 2019',
+          ['civi.tag' => 'deprecated']
+        );
+        $groups[] = 'descendant groups for an org';
+      }
+    }
+    return $groups;
   }
 
 }