From 272dfdc3614e36ff91d3f4f7d4344c69b1fd3d3c Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 30 Jul 2020 15:27:24 +1200 Subject: [PATCH] Cache loader - remove legacy handling, handle null result from setting We are seeing this symptom in our tests in some cases https://civicrm.stackexchange.com/questions/28897/error-when-merging-accounts I'm not quite sure why the setting would be empty - but treating empty the same as 'default' seems better than a hard fail and we know that settings have a track history of not all being loaded at the right times. This also removes some legacy handling --- Civi/Core/Container.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Civi/Core/Container.php b/Civi/Core/Container.php index 617b6dee2c..5b96e40ef0 100644 --- a/Civi/Core/Container.php +++ b/Civi/Core/Container.php @@ -210,7 +210,7 @@ class Container { ->setFactory('CRM_Utils_Mail::createMailer'); if (empty(\Civi::$statics[__CLASS__]['boot'])) { - throw new \RuntimeException("Cannot initialize container. Boot services are undefined."); + throw new \RuntimeException('Cannot initialize container. Boot services are undefined.'); } foreach (\Civi::$statics[__CLASS__]['boot'] as $bootService => $def) { $container->setDefinition($bootService, new Definition())->setSynthetic(TRUE)->setPublic(TRUE); @@ -461,20 +461,19 @@ class Container { */ public static function createPrevNextCache($container) { $setting = \Civi::settings()->get('prevNextBackend'); - if ($setting === 'default') { - // For initial release (5.8.x), continue defaulting to SQL. - $isTransitional = version_compare(\CRM_Utils_System::version(), '5.9.alpha1', '<'); + if (!$setting || $setting === 'default') { $cacheDriver = \CRM_Utils_Cache::getCacheDriver(); $service = 'prevnext.driver.' . strtolower($cacheDriver); - return $container->has($service) && !$isTransitional + return $container->has($service) ? $container->get($service) : $container->get('prevnext.driver.sql'); } - else { - return $container->get('prevnext.driver.' . $setting); - } + return $container->get('prevnext.driver.' . $setting); } + /** + * @return \ArrayObject + */ public static function createCacheConfig() { $driver = \CRM_Utils_Cache::getCacheDriver(); $settings = \CRM_Utils_Cache::getCacheSettings($driver); @@ -548,6 +547,11 @@ class Container { } } + /** + * @param string $name + * + * @return mixed + */ public static function getBootService($name) { return \Civi::$statics[__CLASS__]['boot'][$name]; } -- 2.25.1