From 41ad7727f0e070463fec8a3bfae302cd3fb23052 Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Tue, 8 Sep 2015 13:10:01 +1200 Subject: [PATCH] wmf: CRM-10700 use DELETE FROM instead of TRUNCATE The performance of TRUNCATE is slower than DELETE FROM. Probably due to Note that this provides a way to stop hacking core https://github.com/civicrm/civicrm-packages/pull/180 --- CRM/ACL/BAO/Cache.php | 4 ++-- CRM/Core/Config.php | 12 ++++++------ CRM/Core/Menu.php | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CRM/ACL/BAO/Cache.php b/CRM/ACL/BAO/Cache.php index 1080be600f71..60b58a72ee59 100644 --- a/CRM/ACL/BAO/Cache.php +++ b/CRM/ACL/BAO/Cache.php @@ -157,11 +157,11 @@ public static function resetCache() { // CRM_Core_DAO::singleValueQuery("DELETE FROM civicrm_acl_contact_cache"); // Transaction-safe if (CRM_Core_Transaction::isActive()) { CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_COMMIT, function () { - CRM_Core_DAO::singleValueQuery("TRUNCATE TABLE civicrm_acl_contact_cache"); + CRM_Core_DAO::singleValueQuery("DELETE FROM civicrm_acl_contact_cache"); }); } else { - CRM_Core_DAO::singleValueQuery("TRUNCATE TABLE civicrm_acl_contact_cache"); + CRM_Core_DAO::singleValueQuery("DELETE FROM civicrm_acl_contact_cache"); } } diff --git a/CRM/Core/Config.php b/CRM/Core/Config.php index a942d7ffccd3..83f7341a611f 100644 --- a/CRM/Core/Config.php +++ b/CRM/Core/Config.php @@ -332,13 +332,13 @@ public function clearModuleList() { */ public static function clearDBCache() { $queries = [ - 'TRUNCATE TABLE civicrm_acl_cache', - 'TRUNCATE TABLE civicrm_acl_contact_cache', - 'TRUNCATE TABLE civicrm_cache', - 'TRUNCATE TABLE civicrm_prevnext_cache', + 'DELETE FROM civicrm_acl_cache', + 'DELETE FROM civicrm_acl_contact_cache', + 'DELETE FROM civicrm_cache', + 'DELETE FROM civicrm_prevnext_cache', 'UPDATE civicrm_group SET cache_date = NULL', - 'TRUNCATE TABLE civicrm_group_contact_cache', - 'TRUNCATE TABLE civicrm_menu', + 'DELETE FROM civicrm_group_contact_cache', + 'DELETE FROM civicrm_menu', 'UPDATE civicrm_setting SET value = NULL WHERE name="navigation" AND contact_id IS NOT NULL', ]; diff --git a/CRM/Core/Menu.php b/CRM/Core/Menu.php index ceb7e2a98cdf..677af6a5aa83 100644 --- a/CRM/Core/Menu.php +++ b/CRM/Core/Menu.php @@ -284,7 +284,7 @@ public static function build(&$menu) { public static function store($truncate = TRUE) { // first clean up the db if ($truncate) { - $query = 'TRUNCATE civicrm_menu'; + $query = 'DELETE FROM civicrm_menu'; CRM_Core_DAO::executeQuery($query); } $menuArray = self::items($truncate);