From: Eileen McNaughton Date: Tue, 7 Mar 2023 02:51:55 +0000 (+1300) Subject: Remove some deprecated del calls X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=8fed8f5cd6d7e7c8d676ea8f5b7a15e52dc4a261;p=civicrm-core.git Remove some deprecated del calls --- diff --git a/CRM/Admin/Form/ContactType.php b/CRM/Admin/Form/ContactType.php index 20bedf59c5..77b92cb89a 100644 --- a/CRM/Admin/Form/ContactType.php +++ b/CRM/Admin/Form/ContactType.php @@ -117,11 +117,11 @@ class CRM_Admin_Form_ContactType extends CRM_Admin_Form { CRM_Utils_System::flushCache(); if ($this->_action & CRM_Core_Action::DELETE) { - $isDelete = CRM_Contact_BAO_ContactType::del($this->_id); - if ($isDelete) { + try { + CRM_Contact_BAO_ContactType::deleteRecord(['id' => $this->_id]); CRM_Core_Session::setStatus(ts('Selected contact type has been deleted.'), ts('Record Deleted'), 'success'); } - else { + catch (CRM_Core_Exception $e) { CRM_Core_Session::setStatus(ts("Selected contact type can not be deleted. Make sure contact type doesn't have any associated custom data or group."), ts('Sorry'), 'error'); } return; diff --git a/CRM/Contact/BAO/ContactType.php b/CRM/Contact/BAO/ContactType.php index d02752fe9d..05f9177e4c 100644 --- a/CRM/Contact/BAO/ContactType.php +++ b/CRM/Contact/BAO/ContactType.php @@ -459,6 +459,7 @@ WHERE subtype.name IN ('" . implode("','", $subType) . "' )"; * @return bool */ public static function del($contactTypeId) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); if (!$contactTypeId) { return FALSE; } diff --git a/CRM/Core/Form/RecurringEntity.php b/CRM/Core/Form/RecurringEntity.php index 05435a6aa8..04d4a5e5ca 100644 --- a/CRM/Core/Form/RecurringEntity.php +++ b/CRM/Core/Form/RecurringEntity.php @@ -364,7 +364,7 @@ class CRM_Core_Form_RecurringEntity { 'name' ); if ($optionGroupIdExists) { - CRM_Core_BAO_OptionGroup::del($optionGroupIdExists); + CRM_Core_BAO_OptionGroup::deleteRecord(['id' => $optionGroupIdExists]); } $optionGroupParams = [ 'name' => $type . '_repeat_exclude_dates_' . $actionScheduleObj->entity_value, diff --git a/CRM/Extension/Manager/Report.php b/CRM/Extension/Manager/Report.php index 06160d34fb..45f1adae1c 100644 --- a/CRM/Extension/Manager/Report.php +++ b/CRM/Extension/Manager/Report.php @@ -79,7 +79,7 @@ class CRM_Extension_Manager_Report extends CRM_Extension_Manager_Base { $customReports = $this->getCustomReportsByName(); $cr = $this->getCustomReportsById(); $id = $cr[$customReports[$info->key]]; - $optionValue = CRM_Core_BAO_OptionValue::del($id); + $optionValue = CRM_Core_BAO_OptionValue::deleteRecord(['id' => $id]); return $optionValue ? TRUE : FALSE; } diff --git a/CRM/Extension/Manager/Search.php b/CRM/Extension/Manager/Search.php index 2f3910896c..c251555bca 100644 --- a/CRM/Extension/Manager/Search.php +++ b/CRM/Extension/Manager/Search.php @@ -77,7 +77,7 @@ class CRM_Extension_Manager_Search extends CRM_Extension_Manager_Base { $cs = $this->getCustomSearchesById(); $id = $cs[$customSearchesByName[$info->key]]; - CRM_Core_BAO_OptionValue::del($id); + CRM_Core_BAO_OptionValue::deleteRecord(['id' => $id]); return TRUE; } diff --git a/CRM/Report/BAO/ReportInstance.php b/CRM/Report/BAO/ReportInstance.php index 930b44aad1..1554cc0cce 100644 --- a/CRM/Report/BAO/ReportInstance.php +++ b/CRM/Report/BAO/ReportInstance.php @@ -223,6 +223,7 @@ class CRM_Report_BAO_ReportInstance extends CRM_Report_DAO_ReportInstance implem * @return mixed */ public static function del($id = NULL) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); self::deleteRecord(['id' => $id]); return 1; } @@ -325,7 +326,7 @@ class CRM_Report_BAO_ReportInstance extends CRM_Report_DAO_ReportInstance implem CRM_Core_Error::statusBounce($statusMessage, $bounceTo); } - CRM_Report_BAO_ReportInstance::del($instanceId); + CRM_Report_BAO_ReportInstance::deleteRecord(['id' => $instanceId]); CRM_Core_Session::setStatus(ts('Selected report has been deleted.'), ts('Deleted'), 'success'); if ($successRedirect) { diff --git a/CRM/Report/Form/Register.php b/CRM/Report/Form/Register.php index c4a8f65945..af5c12e4e3 100644 --- a/CRM/Report/Form/Register.php +++ b/CRM/Report/Form/Register.php @@ -158,7 +158,7 @@ class CRM_Report_Form_Register extends CRM_Core_Form { public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { - if (CRM_Core_BAO_OptionValue::del($this->_id)) { + if (CRM_Core_BAO_OptionValue::deleteRecord(['id' => $this->_id])) { CRM_Core_Session::setStatus(ts('Selected %1 Report has been deleted.', [1 => $this->_GName]), ts('Record Deleted'), 'success'); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/report/options/report_template', "reset=1")); } diff --git a/api/v3/ActivityType.php b/api/v3/ActivityType.php index 774e9b3101..6880e6ae7e 100644 --- a/api/v3/ActivityType.php +++ b/api/v3/ActivityType.php @@ -98,7 +98,7 @@ function _civicrm_api3_activity_type_create_spec(&$params) { * @deprecated use OptionValue api */ function civicrm_api3_activity_type_delete($params) { - $result = CRM_Core_BAO_OptionValue::del($params['id']); + $result = CRM_Core_BAO_OptionValue::deleteRecord($params); if ($result) { return civicrm_api3_create_success(TRUE, $params); }