From: Coleman Watts Date: Mon, 20 Mar 2023 15:57:32 +0000 (-0400) Subject: SchemaHandler - Add IF EXISTS to dropTable function X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=1c451a0f2b31d0e37ab6e38d7a76a50c1e60dc6d;p=civicrm-core.git SchemaHandler - Add IF EXISTS to dropTable function --- diff --git a/CRM/Core/BAO/SchemaHandler.php b/CRM/Core/BAO/SchemaHandler.php index 03f39c2dec..62fe656602 100644 --- a/CRM/Core/BAO/SchemaHandler.php +++ b/CRM/Core/BAO/SchemaHandler.php @@ -268,13 +268,13 @@ ALTER TABLE {$tableName} } /** - * Delete a CiviCRM-table. + * Drop a table if it exists. * * @param string $tableName - * Name of the table to be created. + * @throws \Civi\Core\Exception\DBQueryException */ - public static function dropTable($tableName) { - $sql = "DROP TABLE $tableName"; + public static function dropTable(string $tableName): void { + $sql = "DROP TABLE IF EXISTS $tableName"; CRM_Core_DAO::executeQuery($sql); } diff --git a/api/v3/CustomGroup.php b/api/v3/CustomGroup.php index e80f232480..55d5f51774 100644 --- a/api/v3/CustomGroup.php +++ b/api/v3/CustomGroup.php @@ -88,8 +88,9 @@ function _civicrm_api3_custom_group_create_spec(&$params) { function civicrm_api3_custom_group_delete($params) { $values = new CRM_Core_DAO_CustomGroup(); $values->id = $params['id']; - $values->find(TRUE); - + if (!$values->find(TRUE)) { + return civicrm_api3_create_error('Error while deleting custom group'); + } $result = CRM_Core_BAO_CustomGroup::deleteGroup($values, TRUE); return $result ? civicrm_api3_create_success() : civicrm_api3_create_error('Error while deleting custom group'); }