From 7d5ea48bb8792a6b28f9b737e508ec642b2f5496 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 16 Sep 2022 11:07:08 +1200 Subject: [PATCH] Remove references to old temp table names --- CRM/Admin/Form/Setting/UF.php | 4 ++-- CRM/Core/Config.php | 11 +++-------- CRM/Core/DAO.php | 8 +++----- CRM/Logging/Schema.php | 3 ++- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/CRM/Admin/Form/Setting/UF.php b/CRM/Admin/Form/Setting/UF.php index 54078cddc9..f6da3da6de 100644 --- a/CRM/Admin/Form/Setting/UF.php +++ b/CRM/Admin/Form/Setting/UF.php @@ -39,7 +39,7 @@ class CRM_Admin_Form_Setting_UF extends CRM_Admin_Form_Setting { ts('Settings - %1 Integration', [1 => $this->_uf]) ); - if ($this->_uf == 'WordPress') { + if ($this->_uf === 'WordPress') { $this->_settings['wpBasePage'] = CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME; $this->assign('wpBasePageEnabled', TRUE); } @@ -50,7 +50,7 @@ class CRM_Admin_Form_Setting_UF extends CRM_Admin_Form_Setting { } // find out if drupal has its database prefixed - if ($this->_uf == 'Drupal8') { + if ($this->_uf === 'Drupal8') { $databases['default'] = Drupal\Core\Database\Database::getConnectionInfo('default'); } else { diff --git a/CRM/Core/Config.php b/CRM/Core/Config.php index bb3f16131d..77b5f4c74f 100644 --- a/CRM/Core/Config.php +++ b/CRM/Core/Config.php @@ -323,7 +323,7 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge { /** * Clear db cache. */ - public static function clearDBCache() { + public static function clearDBCache(): void { $queries = [ 'TRUNCATE TABLE civicrm_acl_cache', 'TRUNCATE TABLE civicrm_acl_contact_cache', @@ -356,20 +356,15 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge { * Optional time interval for mysql date function.g '2 day'. This can be used to prevent * tables created recently from being deleted. */ - public static function clearTempTables($timeInterval = FALSE) { + public static function clearTempTables($timeInterval = FALSE): void { $dao = new CRM_Core_DAO(); $query = " SELECT TABLE_NAME as tableName FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = %1 - AND ( - TABLE_NAME LIKE 'civicrm_import_job_%' - OR TABLE_NAME LIKE 'civicrm_report_temp%' - OR TABLE_NAME LIKE 'civicrm_tmp_d%' - ) + AND TABLE_NAME LIKE 'civicrm_tmp_d%' "; - // NOTE: Cannot find use-cases where "civicrm_report_temp" would be durable. Could probably remove. if ($timeInterval) { $query .= " AND CREATE_TIME < DATE_SUB(NOW(), INTERVAL {$timeInterval})"; diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 7d91617501..07dd8bb94b 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -1079,16 +1079,16 @@ class CRM_Core_DAO extends DB_DataObject { * * @return array */ - public static function getTableNames() { + public static function getTableNames(): array { $dao = CRM_Core_DAO::executeQuery( "SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '" . CRM_Core_DAO::getDatabaseName() . "' AND TABLE_NAME LIKE 'civicrm_%' - AND TABLE_NAME NOT LIKE 'civicrm_import_job_%' - AND TABLE_NAME NOT LIKE '%_temp%' + AND TABLE_NAME NOT LIKE '%_tmp%' "); + $values = []; while ($dao->fetch()) { $values[] = $dao->TABLE_NAME; } @@ -1107,8 +1107,6 @@ class CRM_Core_DAO extends DB_DataObject { WHERE ENGINE = 'MyISAM' AND TABLE_SCHEMA = '" . CRM_Core_DAO::getDatabaseName() . "' AND TABLE_NAME LIKE 'civicrm_%' - AND TABLE_NAME NOT LIKE 'civicrm_import_job_%' - AND TABLE_NAME NOT LIKE '%_temp%' AND TABLE_NAME NOT LIKE 'civicrm_tmp_%' "); } diff --git a/CRM/Logging/Schema.php b/CRM/Logging/Schema.php index a8ef7185ad..495119f8cc 100644 --- a/CRM/Logging/Schema.php +++ b/CRM/Logging/Schema.php @@ -142,12 +142,13 @@ AND TABLE_NAME LIKE 'civicrm_%' } // do not log temp import, cache, menu and log tables - $this->tables = preg_grep('/^civicrm_import_job_/', $this->tables, PREG_GREP_INVERT); $this->tables = preg_grep('/_cache$/', $this->tables, PREG_GREP_INVERT); $this->tables = preg_grep('/_log/', $this->tables, PREG_GREP_INVERT); $this->tables = preg_grep('/^civicrm_queue_/', $this->tables, PREG_GREP_INVERT); //CRM-14672 $this->tables = preg_grep('/^civicrm_menu/', $this->tables, PREG_GREP_INVERT); + // CiviCRM no longer creates temp tables with `_temp` - they are `tmp` - but this is being left in + // in case extensions do - since we don't want to suddenly start logging them. $this->tables = preg_grep('/_temp_/', $this->tables, PREG_GREP_INVERT); // CRM-18178 $this->tables = preg_grep('/_bak$/', $this->tables, PREG_GREP_INVERT); -- 2.25.1