From 7b2362adcf187c723012ae15b7c2ba95691ef591 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 16 Sep 2022 11:24:49 +1200 Subject: [PATCH] Stop removing Import tables during cache clearing --- CRM/Core/Config.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CRM/Core/Config.php b/CRM/Core/Config.php index 77b5f4c74f..9ffaef16ce 100644 --- a/CRM/Core/Config.php +++ b/CRM/Core/Config.php @@ -377,8 +377,14 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge { } if (!empty($tables)) { $table = implode(',', $tables); - // drop leftover temporary tables - CRM_Core_DAO::executeQuery("DROP TABLE $table"); + // If a User Job references the table do not drop it. This is a bit quick & dirty but we don't want to + // get into calling more sophisticated functions in a cache clear and the table names are pretty unique. + // A separate process will reap the UserJobs but here the goal is just not to delete them during cache clearing + // if they are still referenced. + if (!CRM_Core_DAO::executeQuery("SELECT count(*) FROM civicrm_user_job WHERE metadata LIKE '%" . $tableDAO->tableName . "%'")) { + // drop leftover temporary tables + CRM_Core_DAO::executeQuery("DROP TABLE $table"); + } } } -- 2.25.1