From c6cf61f26229161961c9f6c849f54b1af764dec1 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 21 Jun 2022 03:33:42 -0700 Subject: [PATCH] CRM_Utils_System::flushCache - More consistent behavior. Prepare for interface-php test. * The interface-php test registers an instance of WorkflowMessageInterface. * The list of WorkflowMessageInterface's is stored in the 'long' cache. * When you enable/disable an extension, it should clear WorkflowMessage list (and other things). * Before this patch, interface-php's `LifecycleTest` is inconsistent: it passes with `testLifecycleWithSubprocesses()` and fails with `testLifecycleWithLocalFunctions()`. * After this patch, interface-php's `LifecycleTest` is consistent: it passes with both `testLifecycleWithSubprocesses()` and `testLifecycleWithLocalFunctions()`. * The problem - while executing `testLifecycleWithLocalFunctions()`, it evidentally uses `Arraycache` as the backend -- and thus skips the flushes. However, I cannot fathom why one would want to clear-caches for SQL+memcache+redis but keep them for Arraycache. --- CRM/Utils/System.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index 72946f43ee..757a1c4070 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -1487,13 +1487,7 @@ class CRM_Utils_System { // a bit aggressive, but livable for now CRM_Utils_Cache::singleton()->flush(); - // Traditionally, systems running on memory-backed caches were quite - // zealous about destroying *all* memory-backed caches during a flush(). - // These flushes simulate that legacy behavior. However, they should probably - // be removed at some point. - $localDrivers = ['CRM_Utils_Cache_ArrayCache', 'CRM_Utils_Cache_NoCache']; - if (Civi\Core\Container::isContainerBooted() - && !in_array(get_class(CRM_Utils_Cache::singleton()), $localDrivers)) { + if (Civi\Core\Container::isContainerBooted()) { Civi::cache('long')->flush(); Civi::cache('settings')->flush(); Civi::cache('js_strings')->flush(); -- 2.25.1