diff --git a/CRM/ACL/BAO/ACL.php b/CRM/ACL/BAO/ACL.php index d1166f87ed67..89067de60a4c 100644 --- a/CRM/ACL/BAO/ACL.php +++ b/CRM/ACL/BAO/ACL.php @@ -447,6 +447,7 @@ protected static function matchType($type, $operation) { * @deprecated */ public static function del($aclId) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); self::deleteRecord(['id' => $aclId]); } diff --git a/CRM/ACL/BAO/ACLEntityRole.php b/CRM/ACL/BAO/ACLEntityRole.php index 1e6899d721c8..a892cf4ac70d 100644 --- a/CRM/ACL/BAO/ACLEntityRole.php +++ b/CRM/ACL/BAO/ACLEntityRole.php @@ -39,6 +39,7 @@ public static function entityTables(): array { * @return CRM_ACL_BAO_ACLEntityRole */ public static function create(&$params) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return self::writeRecord($params); } @@ -82,6 +83,7 @@ public static function setIsActive($id, $is_active) { * @deprecated */ public static function del($entityRoleId) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return self::deleteRecord(['id' => $entityRoleId]); } diff --git a/CRM/ACL/Form/ACL.php b/CRM/ACL/Form/ACL.php index bd82aedab0f5..61138975ce3e 100644 --- a/CRM/ACL/Form/ACL.php +++ b/CRM/ACL/Form/ACL.php @@ -247,7 +247,7 @@ public function postProcess() { CRM_Core_BAO_Cache::resetCaches(); if ($this->_action & CRM_Core_Action::DELETE) { - CRM_ACL_BAO_ACL::del($this->_id); + CRM_ACL_BAO_ACL::deleteRecord(['id' => $this->_id]); CRM_Core_Session::setStatus(ts('Selected ACL has been deleted.'), ts('Record Deleted'), 'success'); } else { diff --git a/CRM/Admin/Form/ContactType.php b/CRM/Admin/Form/ContactType.php index 20bedf59c5cc..77b92cb89a55 100644 --- a/CRM/Admin/Form/ContactType.php +++ b/CRM/Admin/Form/ContactType.php @@ -117,11 +117,11 @@ public function postProcess() { 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/Admin/Form/Job.php b/CRM/Admin/Form/Job.php index 3f11c76ac377..00b79fe5180a 100644 --- a/CRM/Admin/Form/Job.php +++ b/CRM/Admin/Form/Job.php @@ -189,7 +189,7 @@ public function postProcess() { CRM_Utils_System::flushCache(); if ($this->_action & CRM_Core_Action::DELETE) { - CRM_Core_BAO_Job::del($this->_id); + CRM_Core_BAO_Job::del(['id' => $this->_id]); CRM_Core_Session::setStatus("", ts('Scheduled Job Deleted.'), "success"); return; } diff --git a/CRM/Admin/Form/LocationType.php b/CRM/Admin/Form/LocationType.php index bfbc0efa2202..e9a687b17c73 100644 --- a/CRM/Admin/Form/LocationType.php +++ b/CRM/Admin/Form/LocationType.php @@ -85,7 +85,7 @@ public function postProcess() { CRM_Utils_System::flushCache(); if ($this->_action & CRM_Core_Action::DELETE) { - CRM_Core_BAO_LocationType::del($this->_id); + CRM_Core_BAO_LocationType::deleteRecord(['id' => $this->_id]); CRM_Core_Session::setStatus(ts('Selected Location type has been deleted.'), ts('Record Deleted'), 'success'); return; } diff --git a/CRM/Admin/Form/Mapping.php b/CRM/Admin/Form/Mapping.php index b924ab1acfce..bf72f47c1d2a 100644 --- a/CRM/Admin/Form/Mapping.php +++ b/CRM/Admin/Form/Mapping.php @@ -83,7 +83,7 @@ public function postProcess() { if ($this->_action == CRM_Core_Action::DELETE) { if ($this->_id) { - CRM_Core_BAO_Mapping::del($this->_id); + CRM_Core_BAO_Mapping::deleteRecord(['id' => $this->_id]); CRM_Core_Session::setStatus(ts('Selected mapping has been deleted successfully.'), ts('Deleted'), 'success'); } } diff --git a/CRM/Admin/Form/MessageTemplates.php b/CRM/Admin/Form/MessageTemplates.php index d4be6aaa9bbb..b38f1ff5a2b5 100644 --- a/CRM/Admin/Form/MessageTemplates.php +++ b/CRM/Admin/Form/MessageTemplates.php @@ -272,7 +272,8 @@ public static function formRule($params, $files, $self) { */ public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { - CRM_Core_BAO_MessageTemplate::del($this->_id); + CRM_Core_BAO_MessageTemplate::deleteRecord(['id' => $this->_id]); + CRM_Core_Session::setStatus(ts('Selected message template has been deleted.'), ts('Deleted'), 'success'); $this->postProcessHook(); } diff --git a/CRM/Admin/Form/OptionGroup.php b/CRM/Admin/Form/OptionGroup.php index 6de152bb9e83..fbf87dfb07cc 100644 --- a/CRM/Admin/Form/OptionGroup.php +++ b/CRM/Admin/Form/OptionGroup.php @@ -120,7 +120,7 @@ public function postProcess() { CRM_Utils_System::flushCache(); if ($this->_action & CRM_Core_Action::DELETE) { - CRM_Core_BAO_OptionGroup::del($this->_id); + CRM_Core_BAO_OptionGroup::deleteRecord(['id' => $this->_id]); CRM_Core_Session::setStatus(ts('Selected option group has been deleted.'), ts('Record Deleted'), 'success'); } else { diff --git a/CRM/Admin/Form/Options.php b/CRM/Admin/Form/Options.php index 5a36fc49ba51..d63a963897b8 100644 --- a/CRM/Admin/Form/Options.php +++ b/CRM/Admin/Form/Options.php @@ -459,7 +459,7 @@ public function postProcess() { $fieldValues = ['option_group_id' => $this->_gid]; CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues); - if (CRM_Core_BAO_OptionValue::del($this->_id)) { + if (CRM_Core_BAO_OptionValue::deleteRecord(['id' => $this->_id])) { if ($this->_gName == 'phone_type') { CRM_Core_BAO_Phone::setOptionToNull(CRM_Utils_Array::value('value', $this->_defaultValues)); } diff --git a/CRM/Admin/Form/PaymentProcessor.php b/CRM/Admin/Form/PaymentProcessor.php index 014727e76b03..1e04b954972d 100644 --- a/CRM/Admin/Form/PaymentProcessor.php +++ b/CRM/Admin/Form/PaymentProcessor.php @@ -407,7 +407,7 @@ public function setDefaultValues() { public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { - CRM_Financial_BAO_PaymentProcessor::del($this->_id); + CRM_Financial_BAO_PaymentProcessor::deleteRecord(['id' => $this->_id]); CRM_Core_Session::setStatus("", ts('Payment Processor Deleted.'), "success"); return NULL; } diff --git a/CRM/Admin/Form/RelationshipType.php b/CRM/Admin/Form/RelationshipType.php index 544807eb504e..c109a2835cd5 100644 --- a/CRM/Admin/Form/RelationshipType.php +++ b/CRM/Admin/Form/RelationshipType.php @@ -161,7 +161,7 @@ public function setDefaultValues() { */ public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { - CRM_Contact_BAO_RelationshipType::del($this->_id); + CRM_Contact_BAO_RelationshipType::deleteRecord(['id' => $this->_id]); CRM_Core_Session::setStatus(ts('Selected Relationship type has been deleted.'), ts('Record Deleted'), 'success'); } else { diff --git a/CRM/Admin/Form/ScheduleReminders.php b/CRM/Admin/Form/ScheduleReminders.php index 67e9bef52766..e042bae1d6fd 100644 --- a/CRM/Admin/Form/ScheduleReminders.php +++ b/CRM/Admin/Form/ScheduleReminders.php @@ -439,7 +439,7 @@ public function setDefaultValues() { public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { // delete reminder - CRM_Core_BAO_ActionSchedule::del($this->_id); + CRM_Core_BAO_ActionSchedule::deleteRecord(['id' => $this->_id]); CRM_Core_Session::setStatus(ts('Selected Reminder has been deleted.'), ts('Record Deleted'), 'success'); if ($this->getContext() === 'event' && $this->getComponentID()) { $url = CRM_Utils_System::url('civicrm/event/manage/reminder', diff --git a/CRM/Badge/BAO/Layout.php b/CRM/Badge/BAO/Layout.php index a662445166bf..dd34add77a4f 100644 --- a/CRM/Badge/BAO/Layout.php +++ b/CRM/Badge/BAO/Layout.php @@ -92,6 +92,7 @@ public static function create(&$params) { * @deprecated */ public static function del($printLabelId) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); self::deleteRecord(['id' => $printLabelId]); } diff --git a/CRM/Badge/Form/Layout.php b/CRM/Badge/Form/Layout.php index 90026c7fe3f1..661fb70ac3b5 100644 --- a/CRM/Badge/Form/Layout.php +++ b/CRM/Badge/Form/Layout.php @@ -164,7 +164,7 @@ public function setDefaultValues() { */ public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { - CRM_Badge_BAO_Layout::del($this->_id); + CRM_Badge_BAO_Layout::deleteRecord(['id' => $this->_id]); CRM_Core_Session::setStatus(ts('Selected badge layout has been deleted.'), ts('Record Deleted'), 'success'); return; } diff --git a/CRM/Batch/BAO/EntityBatch.php b/CRM/Batch/BAO/EntityBatch.php index 3f64e75b33af..18fffa96fac6 100644 --- a/CRM/Batch/BAO/EntityBatch.php +++ b/CRM/Batch/BAO/EntityBatch.php @@ -63,6 +63,7 @@ public static function create($params) { * @return CRM_Batch_DAO_EntityBatch */ public static function del($params) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); if (!is_array($params)) { $params = ['id' => $params]; } diff --git a/CRM/Campaign/BAO/Campaign.php b/CRM/Campaign/BAO/Campaign.php index 2314942c10c7..8229c944cf44 100644 --- a/CRM/Campaign/BAO/Campaign.php +++ b/CRM/Campaign/BAO/Campaign.php @@ -77,6 +77,7 @@ public static function create(&$params) { * @return bool|int */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); try { self::deleteRecord(['id' => $id]); } diff --git a/CRM/Campaign/BAO/Survey.php b/CRM/Campaign/BAO/Survey.php index 136d81b8af36..c6b0bd2aaa09 100644 --- a/CRM/Campaign/BAO/Survey.php +++ b/CRM/Campaign/BAO/Survey.php @@ -363,6 +363,7 @@ public static function setIsActive($id, $is_active) { * @return mixed|null */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); if (!$id) { return NULL; } diff --git a/CRM/Campaign/Form/Campaign.php b/CRM/Campaign/Form/Campaign.php index 838405521b4f..6a3931a1e994 100644 --- a/CRM/Campaign/Form/Campaign.php +++ b/CRM/Campaign/Form/Campaign.php @@ -287,7 +287,7 @@ public function postProcess() { } if (!empty($params['id'])) { if ($this->_action & CRM_Core_Action::DELETE) { - CRM_Campaign_BAO_Campaign::del($params['id']); + CRM_Campaign_BAO_Campaign::deleteRecord(['id' => $params['id']]); CRM_Core_Session::setStatus(ts('Campaign has been deleted.'), ts('Record Deleted'), 'success'); $session->replaceUserContext(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=campaign')); return; diff --git a/CRM/Campaign/Form/Petition.php b/CRM/Campaign/Form/Petition.php index 934779f7ed8f..d52c50e1f5ab 100644 --- a/CRM/Campaign/Form/Petition.php +++ b/CRM/Campaign/Form/Petition.php @@ -296,7 +296,7 @@ public function postProcess() { if ($this->_surveyId) { if ($this->_action & CRM_Core_Action::DELETE) { - CRM_Campaign_BAO_Survey::del($this->_surveyId); + CRM_Campaign_BAO_Survey::deleteRecord(['id' => $this->_surveyId]); CRM_Core_Session::setStatus(ts(' Petition has been deleted.'), ts('Record Deleted'), 'success'); $session->replaceUserContext(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=petition')); return; diff --git a/CRM/Campaign/Form/Survey/Delete.php b/CRM/Campaign/Form/Survey/Delete.php index 16715221eaae..53a7d0c50e0a 100644 --- a/CRM/Campaign/Form/Survey/Delete.php +++ b/CRM/Campaign/Form/Survey/Delete.php @@ -72,7 +72,7 @@ public function buildQuickForm() { */ public function postProcess() { if ($this->_surveyId) { - CRM_Campaign_BAO_Survey::del($this->_surveyId); + CRM_Campaign_BAO_Survey::deleteRecord(['id' => $this->_surveyId]); CRM_Core_Session::setStatus('', ts("'%1' survey has been deleted.", [1 => $this->_surveyTitle]), 'success'); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey')); } diff --git a/CRM/Campaign/Form/Survey/Main.php b/CRM/Campaign/Form/Survey/Main.php index 44b760763e68..72fc38c7c161 100644 --- a/CRM/Campaign/Form/Survey/Main.php +++ b/CRM/Campaign/Form/Survey/Main.php @@ -187,7 +187,7 @@ public function postProcess() { ); // delete option group if no any survey is using it. if (!$countSurvey) { - CRM_Core_BAO_OptionGroup::del($this->_values['result_id']); + CRM_Core_BAO_OptionGroup::deleteRecord(['id' => $this->_values['result_id']]); } } diff --git a/CRM/Campaign/Form/SurveyType.php b/CRM/Campaign/Form/SurveyType.php index 713830405922..02e8836ef5aa 100644 --- a/CRM/Campaign/Form/SurveyType.php +++ b/CRM/Campaign/Form/SurveyType.php @@ -122,7 +122,7 @@ public function postProcess() { $fieldValues = ['option_group_id' => $this->_gid]; $wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues); - if (CRM_Core_BAO_OptionValue::del($this->_id)) { + if (CRM_Core_BAO_OptionValue::deleteRecord(['id' => $this->_id])) { CRM_Core_Session::setStatus(ts('Selected Survey type has been deleted.'), ts('Record Deleted'), 'success'); } } diff --git a/CRM/Case/BAO/CaseType.php b/CRM/Case/BAO/CaseType.php index c3f745786464..8021fa1ea96f 100644 --- a/CRM/Case/BAO/CaseType.php +++ b/CRM/Case/BAO/CaseType.php @@ -439,6 +439,7 @@ public static function retrieve(&$params, &$defaults) { * @return CRM_Case_DAO_CaseType */ public static function del($caseTypeId) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return static::deleteRecord(['id' => $caseTypeId]); } diff --git a/CRM/Contact/BAO/ContactType.php b/CRM/Contact/BAO/ContactType.php index d02752fe9d35..05f9177e4c2e 100644 --- a/CRM/Contact/BAO/ContactType.php +++ b/CRM/Contact/BAO/ContactType.php @@ -459,6 +459,7 @@ public static function getCreateNewList() { * @return bool */ public static function del($contactTypeId) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); if (!$contactTypeId) { return FALSE; } diff --git a/CRM/Contact/BAO/GroupContact.php b/CRM/Contact/BAO/GroupContact.php index b058686ec85d..22d8902d5463 100644 --- a/CRM/Contact/BAO/GroupContact.php +++ b/CRM/Contact/BAO/GroupContact.php @@ -33,6 +33,7 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact implemen * @deprecated */ public static function add(array $params): CRM_Contact_DAO_GroupContact { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return self::writeRecord($params); } @@ -503,7 +504,7 @@ public static function create(array $params) { // As of Aug 2020 it's not called from anywhere so we can remove the below code after some time CRM_Core_Error::deprecatedFunctionWarning('Use the GroupContact API'); - return self::add($params); + return self::writeRecord($params); } /** diff --git a/CRM/Contact/BAO/RelationshipType.php b/CRM/Contact/BAO/RelationshipType.php index 3daef9e626b0..3059ac9e49b5 100644 --- a/CRM/Contact/BAO/RelationshipType.php +++ b/CRM/Contact/BAO/RelationshipType.php @@ -98,12 +98,8 @@ public static function add($params) { * @return mixed */ public static function del($relationshipTypeId) { - // make sure relationshipTypeId is an integer - // @todo review this as most delete functions rely on the api & form layer for this - // or do a find first & throw error if no find - if (!CRM_Utils_Rule::positiveInteger($relationshipTypeId)) { - throw new CRM_Core_Exception(ts('Invalid relationship type')); - } + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); + return static::deleteRecord(['id' => $relationshipTypeId]); } diff --git a/CRM/Contact/Form/Relationship.php b/CRM/Contact/Form/Relationship.php index 41c11d221ad8..47116d7d1759 100644 --- a/CRM/Contact/Form/Relationship.php +++ b/CRM/Contact/Form/Relationship.php @@ -508,7 +508,7 @@ public static function getRelationshipTypeMetadata($relationshipList) { * Relationship ID */ private function deleteAction($id) { - CRM_Contact_BAO_Relationship::del($id); + CRM_Contact_BAO_Relationship::deleteRecord(['id' => $id]); CRM_Core_Session::setStatus(ts('Selected relationship has been deleted successfully.'), ts('Record Deleted'), 'success'); // reload all blocks to reflect this change on the user interface. diff --git a/CRM/Contact/Page/View/Relationship.php b/CRM/Contact/Page/View/Relationship.php index 1b5ce208283d..1740059051e3 100644 --- a/CRM/Contact/Page/View/Relationship.php +++ b/CRM/Contact/Page/View/Relationship.php @@ -181,7 +181,7 @@ public function edit() { } // delete relationship - CRM_Contact_BAO_Relationship::del($this->getEntityId()); + CRM_Contact_BAO_Relationship::deleteRecord(['id' => $this->getEntityId()]); CRM_Core_Session::setStatus(ts('Selected relationship has been deleted successfully.'), ts('Record Deleted'), 'success'); CRM_Utils_System::redirect($url); @@ -240,7 +240,7 @@ public function setContext() { */ public function delete() { // calls a function to delete relationship - CRM_Contact_BAO_Relationship::del($this->getEntityId()); + CRM_Contact_BAO_Relationship::deleteRecord(['id' => $this->getEntityId()]); CRM_Core_Session::setStatus(ts('Selected relationship has been deleted successfully.'), ts('Record Deleted'), 'success'); } diff --git a/CRM/Contribute/BAO/ManagePremiums.php b/CRM/Contribute/BAO/ManagePremiums.php index a8e6033e70ab..90bf3d850b1d 100644 --- a/CRM/Contribute/BAO/ManagePremiums.php +++ b/CRM/Contribute/BAO/ManagePremiums.php @@ -84,9 +84,8 @@ public static function add(&$params, $ids) { * @throws \CRM_Core_Exception */ public static function del($productID) { - CRM_Core_Error::deprecatedFunctionWarning('CRM_Contribute_BAO_Product::del'); - return parent::del($productID); - // Stop this showing up when we're looking for undeprecated del's by keeping this: static::deleteRecord( + CRM_Core_Error::deprecatedFunctionWarning('CRM_Contribute_BAO_Product::deleteRecord'); + return parent::deleteRecord(['id' => $productID]); } } diff --git a/CRM/Contribute/BAO/Premium.php b/CRM/Contribute/BAO/Premium.php index 8b577b7bc6ae..4b03e896a5fa 100644 --- a/CRM/Contribute/BAO/Premium.php +++ b/CRM/Contribute/BAO/Premium.php @@ -59,6 +59,7 @@ public static function setIsActive($id, $is_active) { * @deprecated */ public static function del($premiumID) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return static::deleteRecord(['id' => $premiumID]); } diff --git a/CRM/Contribute/BAO/Product.php b/CRM/Contribute/BAO/Product.php index 7c7f9ff164a3..754106904e0d 100644 --- a/CRM/Contribute/BAO/Product.php +++ b/CRM/Contribute/BAO/Product.php @@ -110,6 +110,7 @@ public static function create($params) { * @throws \CRM_Core_Exception */ public static function del($productID) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); static::deleteRecord(['id' => $productID]); } diff --git a/CRM/Contribute/Form/ManagePremiums.php b/CRM/Contribute/Form/ManagePremiums.php index ab930809a85b..965c67f4ae37 100644 --- a/CRM/Contribute/Form/ManagePremiums.php +++ b/CRM/Contribute/Form/ManagePremiums.php @@ -259,7 +259,7 @@ public function postProcess() { // If deleting, then only delete and skip the rest of the post-processing if ($this->_action & CRM_Core_Action::DELETE) { try { - CRM_Contribute_BAO_Product::del($this->_id); + CRM_Contribute_BAO_Product::deleteRecord(['id' => $this->_id]); } catch (CRM_Core_Exception $e) { $message = ts("This Premium is linked to an Online Contribution page. Please remove it before deleting this Premium.", [1 => CRM_Utils_System::url('civicrm/admin/contribute', 'reset=1')]); diff --git a/CRM/Core/BAO/ActionSchedule.php b/CRM/Core/BAO/ActionSchedule.php index 8307501bb60d..3ff899d91cb1 100644 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -179,6 +179,7 @@ public static function getList($filterMapping = NULL, $filterValue = NULL): arra * @throws \CRM_Core_Exception */ public static function add(array $params): CRM_Core_DAO_ActionSchedule { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return self::writeRecord($params); } @@ -210,6 +211,7 @@ public static function retrieve($params, &$defaults) { * @throws CRM_Core_Exception */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); self::deleteRecord(['id' => $id]); } diff --git a/CRM/Core/BAO/Address.php b/CRM/Core/BAO/Address.php index e44f9c90d2fd..57576ecf3b49 100644 --- a/CRM/Core/BAO/Address.php +++ b/CRM/Core/BAO/Address.php @@ -1212,6 +1212,7 @@ public static function setSharedAddressDeleteStatus($addressId = NULL, $contactI * @return bool */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return (bool) self::deleteRecord(['id' => $id]); } diff --git a/CRM/Core/BAO/Block.php b/CRM/Core/BAO/Block.php index 9ad00682c21a..506e9515763b 100644 --- a/CRM/Core/BAO/Block.php +++ b/CRM/Core/BAO/Block.php @@ -264,7 +264,7 @@ public static function create($blockName, $params) { // $updateBlankLocInfo will help take appropriate decision. CRM-5969 if (!empty($value['id']) && !$dataExists && $updateBlankLocInfo) { //delete the existing record - $baoString::del($value['id']); + $baoString::deleteRecord($value); continue; } elseif (!$dataExists) { @@ -307,7 +307,7 @@ public static function blockDelete($blockName, $params) { } $baoString = 'CRM_Core_BAO_' . $name; - $baoString::del($params['id']); + $baoString::deleteRecord($params); } /** diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index 05900d6caf0a..67cc1142d5a8 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -2485,7 +2485,7 @@ public static function checkOptionGroup($optionGroupId) { if ($count < 2) { //delete the option group - CRM_Core_BAO_OptionGroup::del($optionGroupId); + CRM_Core_BAO_OptionGroup::deleteRecord(['id' => $optionGroupId]); } } diff --git a/CRM/Core/BAO/Domain.php b/CRM/Core/BAO/Domain.php index a7bb9a9ace2d..c3642ccbab09 100644 --- a/CRM/Core/BAO/Domain.php +++ b/CRM/Core/BAO/Domain.php @@ -166,6 +166,7 @@ public static function edit($params, $id): CRM_Core_DAO_Domain { * @return CRM_Core_DAO_Domain */ public static function create($params) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return self::writeRecord($params); } diff --git a/CRM/Core/BAO/Email.php b/CRM/Core/BAO/Email.php index 0f5ce646710c..e7e4eb9a1dc3 100644 --- a/CRM/Core/BAO/Email.php +++ b/CRM/Core/BAO/Email.php @@ -355,6 +355,7 @@ public static function isMultipleBulkMail() { * @return bool */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return (bool) self::deleteRecord(['id' => $id]); } diff --git a/CRM/Core/BAO/Extension.php b/CRM/Core/BAO/Extension.php index 351db0f8b18c..4bb87024ed95 100644 --- a/CRM/Core/BAO/Extension.php +++ b/CRM/Core/BAO/Extension.php @@ -48,6 +48,7 @@ public static function retrieve($params, &$defaults) { * @deprecated */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return (bool) static::deleteRecord(['id' => $id]); } diff --git a/CRM/Core/BAO/IM.php b/CRM/Core/BAO/IM.php index a410e912746a..b1a916c374d3 100644 --- a/CRM/Core/BAO/IM.php +++ b/CRM/Core/BAO/IM.php @@ -163,6 +163,7 @@ public static function allEntityIMs(&$entityElements) { * @return bool */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return (bool) self::deleteRecord(['id' => $id]); } diff --git a/CRM/Core/BAO/Job.php b/CRM/Core/BAO/Job.php index aecf92d79dba..c8c849d381c1 100644 --- a/CRM/Core/BAO/Job.php +++ b/CRM/Core/BAO/Job.php @@ -76,6 +76,7 @@ public static function setIsActive($id, $is_active) { * @throws CRM_Core_Exception */ public static function del($jobID) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); self::deleteRecord(['id' => $jobID]); return TRUE; } diff --git a/CRM/Core/BAO/LocationType.php b/CRM/Core/BAO/LocationType.php index 6d119d709164..3200e149d1ce 100644 --- a/CRM/Core/BAO/LocationType.php +++ b/CRM/Core/BAO/LocationType.php @@ -121,6 +121,7 @@ public static function create(&$params) { * @deprecated */ public static function del($locationTypeId) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); static::deleteRecord(['id' => $locationTypeId]); } diff --git a/CRM/Core/BAO/Mapping.php b/CRM/Core/BAO/Mapping.php index a64a2176ab8d..f184420c3306 100644 --- a/CRM/Core/BAO/Mapping.php +++ b/CRM/Core/BAO/Mapping.php @@ -42,6 +42,7 @@ public static function retrieve($params, &$defaults) { * @return bool */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return (bool) static::deleteRecord(['id' => $id]); } diff --git a/CRM/Core/BAO/MessageTemplate.php b/CRM/Core/BAO/MessageTemplate.php index 12fe6914c7dc..be77c649dd74 100644 --- a/CRM/Core/BAO/MessageTemplate.php +++ b/CRM/Core/BAO/MessageTemplate.php @@ -165,14 +165,8 @@ public static function add(&$params) { * @throws \CRM_Core_Exception */ public static function del($messageTemplatesID) { - // make sure messageTemplatesID is an integer - if (!CRM_Utils_Rule::positiveInteger($messageTemplatesID)) { - throw new CRM_Core_Exception(ts('Invalid Message template')); - } - + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); static::deleteRecord(['id' => $messageTemplatesID]); - // Yikes - bad idea setting status messages in BAO CRUD functions. Don't do this. - CRM_Core_Session::setStatus(ts('Selected message template has been deleted.'), ts('Deleted'), 'success'); } /** diff --git a/CRM/Core/BAO/Note.php b/CRM/Core/BAO/Note.php index b8abef965f65..f2eb16f1b698 100644 --- a/CRM/Core/BAO/Note.php +++ b/CRM/Core/BAO/Note.php @@ -276,7 +276,7 @@ public static function self_hook_civicrm_pre(\Civi\Core\Event\PreEvent $event) { * @return int */ public static function del($id) { - // CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); self::deleteRecord(['id' => $id]); return 1; diff --git a/CRM/Core/BAO/OpenID.php b/CRM/Core/BAO/OpenID.php index 2e1e1576a192..c82a42dfabef 100644 --- a/CRM/Core/BAO/OpenID.php +++ b/CRM/Core/BAO/OpenID.php @@ -126,6 +126,7 @@ public static function allOpenIDs($id, $updateBlankLocInfo = FALSE) { * @return bool */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return (bool) self::deleteRecord(['id' => $id]); } diff --git a/CRM/Core/BAO/OptionGroup.php b/CRM/Core/BAO/OptionGroup.php index 09e21694236c..2d1da9c0ff66 100644 --- a/CRM/Core/BAO/OptionGroup.php +++ b/CRM/Core/BAO/OptionGroup.php @@ -86,6 +86,7 @@ public static function add(&$params, $ids = []) { * @param int $optionGroupId */ public static function del($optionGroupId) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); static::deleteRecord(['id' => $optionGroupId]); } diff --git a/CRM/Core/BAO/OptionValue.php b/CRM/Core/BAO/OptionValue.php index aeff6e50a408..cd9c7e0fd92c 100644 --- a/CRM/Core/BAO/OptionValue.php +++ b/CRM/Core/BAO/OptionValue.php @@ -230,6 +230,7 @@ public static function add(&$params) { * @deprecated */ public static function del($optionValueId) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return (bool) static::deleteRecord(['id' => $optionValueId]); } diff --git a/CRM/Core/BAO/Phone.php b/CRM/Core/BAO/Phone.php index 3ed91d733b3c..cf095fa29a6d 100644 --- a/CRM/Core/BAO/Phone.php +++ b/CRM/Core/BAO/Phone.php @@ -236,6 +236,7 @@ public static function setOptionToNull($optionId) { * @return bool */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return (bool) self::deleteRecord(['id' => $id]); } diff --git a/CRM/Core/BAO/RecurringEntity.php b/CRM/Core/BAO/RecurringEntity.php index 5e3e4c2d4be6..c34c25bdafa6 100644 --- a/CRM/Core/BAO/RecurringEntity.php +++ b/CRM/Core/BAO/RecurringEntity.php @@ -149,6 +149,7 @@ public static function setStatus($status) { * @return CRM_Core_DAO_RecurringEntity */ public static function add($params) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return self::writeRecord($params); } diff --git a/CRM/Core/BAO/Tag.php b/CRM/Core/BAO/Tag.php index e2c8422f19ae..7991e8cb73d1 100644 --- a/CRM/Core/BAO/Tag.php +++ b/CRM/Core/BAO/Tag.php @@ -350,6 +350,7 @@ public static function getColorTags($usedFor = NULL, $allowSelectingNonSelectabl * @return bool */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return (bool) static::deleteRecord(['id' => $id]); } diff --git a/CRM/Core/BAO/UFField.php b/CRM/Core/BAO/UFField.php index ae8a9dd90754..82cfeb08580e 100644 --- a/CRM/Core/BAO/UFField.php +++ b/CRM/Core/BAO/UFField.php @@ -164,6 +164,7 @@ public static function setIsActive($id, $is_active) { * @return bool */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return (bool) self::deleteRecord(['id' => $id]); } @@ -319,7 +320,7 @@ public static function delUFField($customFieldId) { $ufField->find(); while ($ufField->fetch()) { //enable/ disable profile - CRM_Core_BAO_UFField::del($ufField->id); + CRM_Core_BAO_UFField::deleteRecord(['id' => $ufField->id]); } } diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index 44ea26425c1f..43c3317b248f 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -1404,6 +1404,7 @@ public static function usedByModule($id) { * @deprecated */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return (bool) static::deleteRecord(['id' => $id]); } diff --git a/CRM/Core/BAO/Website.php b/CRM/Core/BAO/Website.php index aafd8e8a5181..14c740d694fb 100644 --- a/CRM/Core/BAO/Website.php +++ b/CRM/Core/BAO/Website.php @@ -31,6 +31,7 @@ class CRM_Core_BAO_Website extends CRM_Core_DAO_Website { * @throws \CRM_Core_Exception */ public static function create($params) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return self::writeRecord($params); } @@ -81,7 +82,7 @@ public static function process($params, $contactID, $skipDelete) { } if (!empty($values['url'])) { $values['contact_id'] = $contactID; - self::create($values); + self::writeRecord($values); } elseif ($skipDelete && !empty($values['id'])) { static::deleteRecord($values); @@ -99,6 +100,7 @@ public static function process($params, $contactID, $skipDelete) { * @deprecated */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return (bool) static::deleteRecord(['id' => $id]); } diff --git a/CRM/Core/BAO/WordReplacement.php b/CRM/Core/BAO/WordReplacement.php index 0cf4af17a4f0..e3429a12b082 100644 --- a/CRM/Core/BAO/WordReplacement.php +++ b/CRM/Core/BAO/WordReplacement.php @@ -65,6 +65,7 @@ public static function edit(&$params, &$id) { * @return array */ public static function create($params) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); if (array_key_exists("domain_id", $params) === FALSE) { $params["domain_id"] = CRM_Core_Config::domainID(); } @@ -85,6 +86,7 @@ public static function create($params) { * @return CRM_Core_DAO_WordReplacement */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return static::deleteRecord(['id' => $id]); } diff --git a/CRM/Core/Form/RecurringEntity.php b/CRM/Core/Form/RecurringEntity.php index 05435a6aa857..52ba505fdcb1 100644 --- a/CRM/Core/Form/RecurringEntity.php +++ b/CRM/Core/Form/RecurringEntity.php @@ -346,10 +346,10 @@ public static function postProcess($params, $type, $linkedEntities = []) { //Delete repeat configuration and rebuild if (!empty($params['id'])) { - CRM_Core_BAO_ActionSchedule::del($params['id']); + CRM_Core_BAO_ActionSchedule::deleteRecord($params); unset($params['id']); } - $actionScheduleObj = CRM_Core_BAO_ActionSchedule::add($dbParams); + $actionScheduleObj = CRM_Core_BAO_ActionSchedule::writeRecord($dbParams); //exclude dates $excludeDateList = []; @@ -364,7 +364,7 @@ public static function postProcess($params, $type, $linkedEntities = []) { '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/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 23d26017feb7..62c1a0438911 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -172,6 +172,7 @@ public static function create(&$params) { * @deprecated */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return (bool) static::deleteRecord(['id' => $id]); } diff --git a/CRM/Event/Form/ManageEvent/Delete.php b/CRM/Event/Form/ManageEvent/Delete.php index 6260b2639ab4..8b6511aed742 100644 --- a/CRM/Event/Form/ManageEvent/Delete.php +++ b/CRM/Event/Form/ManageEvent/Delete.php @@ -81,7 +81,7 @@ public function postProcess() { ), ts('Deletion Error'), 'error'); return; } - CRM_Event_BAO_Event::del($this->_id); + CRM_Event_BAO_Event::deleteRecord(['id' => $this->_id]); if ($this->_isTemplate) { CRM_Core_Session::setStatus(ts("'%1' has been deleted.", [1 => $this->_title]), ts('Template Deleted'), 'success'); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/eventTemplate', 'reset=1')); diff --git a/CRM/Extension/Manager.php b/CRM/Extension/Manager.php index b64bcc23f129..6b1f1cfb598f 100644 --- a/CRM/Extension/Manager.php +++ b/CRM/Extension/Manager.php @@ -700,11 +700,12 @@ private function _removeExtensionEntry(CRM_Extension_Info $info) { $dao = new CRM_Core_DAO_Extension(); $dao->full_name = $info->key; if ($dao->find(TRUE)) { - if (CRM_Core_BAO_Extension::del($dao->id)) { + try { + CRM_Core_BAO_Extension::deleteRecord(['id' => $dao->id]); CRM_Core_Session::setStatus(ts('Selected option value has been deleted.'), ts('Deleted'), 'success'); } - else { - throw new CRM_Extension_Exception("Failed to remove extension entry"); + catch (CRM_Core_Exception $e) { + throw new CRM_Extension_Exception("Failed to remove extension entry $dao->id"); } } // else: post-condition already satisified } diff --git a/CRM/Extension/Manager/Report.php b/CRM/Extension/Manager/Report.php index 06160d34fb33..45f1adae1c60 100644 --- a/CRM/Extension/Manager/Report.php +++ b/CRM/Extension/Manager/Report.php @@ -79,7 +79,7 @@ public function onPreUninstall(CRM_Extension_Info $info) { $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 2f3910896c32..c251555bcaec 100644 --- a/CRM/Extension/Manager/Search.php +++ b/CRM/Extension/Manager/Search.php @@ -77,7 +77,7 @@ public function onPreUninstall(CRM_Extension_Info $info) { $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/Financial/BAO/EntityFinancialAccount.php b/CRM/Financial/BAO/EntityFinancialAccount.php index c2d8839d5d67..283247a51683 100644 --- a/CRM/Financial/BAO/EntityFinancialAccount.php +++ b/CRM/Financial/BAO/EntityFinancialAccount.php @@ -205,7 +205,7 @@ public static function createDefaultFinancialAccounts($financialType) { 'account_type_code' => 'INC', 'is_active' => 1, ]; - $financialAccount = CRM_Financial_BAO_FinancialAccount::add($params); + $financialAccount = CRM_Financial_BAO_FinancialAccount::writeRecord($params); } else { $existingFinancialAccount[$dao->financial_account_type_id] = $dao->id; diff --git a/CRM/Financial/BAO/FinancialAccount.php b/CRM/Financial/BAO/FinancialAccount.php index 77f65011ace5..5e04cda5c295 100644 --- a/CRM/Financial/BAO/FinancialAccount.php +++ b/CRM/Financial/BAO/FinancialAccount.php @@ -57,6 +57,7 @@ public static function setIsActive($id, $is_active) { * @return CRM_Financial_DAO_FinancialAccount */ public static function add($params) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return self::writeRecord($params); } diff --git a/CRM/Financial/BAO/FinancialType.php b/CRM/Financial/BAO/FinancialType.php index e832df68ae05..d02b7c8fe806 100644 --- a/CRM/Financial/BAO/FinancialType.php +++ b/CRM/Financial/BAO/FinancialType.php @@ -71,6 +71,7 @@ public static function setIsActive($id, $is_active) { * @deprecated */ public static function create(array $params) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return self::writeRecord($params); } @@ -88,6 +89,7 @@ public static function create(array $params) { * @deprecated */ public static function add(array $params, $ids = []) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return self::writeRecord($params); } @@ -99,6 +101,7 @@ public static function add(array $params, $ids = []) { * @return array|bool */ public static function del($financialTypeId) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); try { static::deleteRecord(['id' => $financialTypeId]); return TRUE; diff --git a/CRM/Financial/BAO/PaymentProcessor.php b/CRM/Financial/BAO/PaymentProcessor.php index 99ad17f8cffb..d15066d9ceac 100644 --- a/CRM/Financial/BAO/PaymentProcessor.php +++ b/CRM/Financial/BAO/PaymentProcessor.php @@ -180,9 +180,7 @@ public static function &getDefault() { * @deprecated */ public static function del($paymentProcessorID) { - if (!$paymentProcessorID) { - throw new CRM_Core_Exception(ts('Invalid value passed to delete function.')); - } + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); static::deleteRecord(['id' => $paymentProcessorID]); } diff --git a/CRM/Financial/Form/FinancialAccount.php b/CRM/Financial/Form/FinancialAccount.php index 8c52ce6fc2e0..c90572a32644 100644 --- a/CRM/Financial/Form/FinancialAccount.php +++ b/CRM/Financial/Form/FinancialAccount.php @@ -209,7 +209,7 @@ public function postProcess() { ] as $field) { $params[$field] = CRM_Utils_Array::value($field, $params, FALSE); } - $financialAccount = CRM_Financial_BAO_FinancialAccount::add($params); + $financialAccount = CRM_Financial_BAO_FinancialAccount::writeRecord($params); CRM_Core_Session::setStatus(ts('The Financial Account \'%1\' has been saved.', [1 => $financialAccount->name]), ts('Saved'), 'success'); } } diff --git a/CRM/Financial/Form/FinancialType.php b/CRM/Financial/Form/FinancialType.php index 9d1c0fdfb664..a9cd27ee26f4 100644 --- a/CRM/Financial/Form/FinancialType.php +++ b/CRM/Financial/Form/FinancialType.php @@ -117,9 +117,11 @@ public function buildQuickForm() { */ public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { - $errors = CRM_Financial_BAO_FinancialType::del($this->_id); - if (is_array($errors) && !empty($errors)) { - CRM_Core_Error::statusBounce($errors['error_message'], CRM_Utils_System::url('civicrm/admin/financial/financialType', "reset=1&action=browse"), ts('Cannot Delete')); + try { + CRM_Financial_BAO_FinancialType::deleteRecord(['id' => $this->_id]); + } + catch (CRM_Core_Exception $e) { + CRM_Core_Error::statusBounce($e->getMessage(), CRM_Utils_System::url('civicrm/admin/financial/financialType', "reset=1&action=browse"), ts('Cannot Delete')); } CRM_Core_Session::setStatus(ts('Selected financial type has been deleted.'), ts('Record Deleted'), 'success'); } diff --git a/CRM/Mailing/BAO/Mailing.php b/CRM/Mailing/BAO/Mailing.php index e772bac2701a..2ca7e67f9c07 100644 --- a/CRM/Mailing/BAO/Mailing.php +++ b/CRM/Mailing/BAO/Mailing.php @@ -2405,6 +2405,7 @@ public static function showEmailDetails($id) { * @deprecated */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); static::deleteRecord(['id' => $id]); } @@ -2436,7 +2437,7 @@ public static function delJob($id) { CRM_Core_Error::deprecatedWarning('This function is deprecated, use CRM_Mailing_BAO_MailingJob::del instead'); - CRM_Mailing_BAO_MailingJob::del($id); + CRM_Mailing_BAO_MailingJob::deleteRecord(['id' => $id]); } /** diff --git a/CRM/Mailing/BAO/MailingAB.php b/CRM/Mailing/BAO/MailingAB.php index 73ce87482176..681f90d4ce71 100644 --- a/CRM/Mailing/BAO/MailingAB.php +++ b/CRM/Mailing/BAO/MailingAB.php @@ -52,6 +52,7 @@ public static function create(&$params) { * @deprecated */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); static::deleteRecord(['id' => $id]); } diff --git a/CRM/Mailing/BAO/MailingJob.php b/CRM/Mailing/BAO/MailingJob.php index 2522030c6a30..d8de39f04ca2 100644 --- a/CRM/Mailing/BAO/MailingJob.php +++ b/CRM/Mailing/BAO/MailingJob.php @@ -1102,6 +1102,7 @@ public static function findPendingTasks($jobId, $medium) { * @return bool */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return (bool) self::deleteRecord(['id' => $id]); } diff --git a/CRM/Mailing/Form/Approve.php b/CRM/Mailing/Form/Approve.php index 1cd4140b037a..a777d4f5b00c 100644 --- a/CRM/Mailing/Form/Approve.php +++ b/CRM/Mailing/Form/Approve.php @@ -155,7 +155,7 @@ public function postProcess() { $job = new CRM_Mailing_BAO_MailingJob(); $job->mailing_id = $params['id']; while ($job->fetch()) { - CRM_Mailing_BAO_MailingJob::del($job->id); + CRM_Mailing_BAO_MailingJob::deleteRecord(['id' => $job->id]); } } else { diff --git a/CRM/Mailing/Form/Browse.php b/CRM/Mailing/Form/Browse.php index 9b221b4de85c..a8936bdd9511 100644 --- a/CRM/Mailing/Form/Browse.php +++ b/CRM/Mailing/Form/Browse.php @@ -61,7 +61,7 @@ public function buildQuickForm() { public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { - CRM_Mailing_BAO_Mailing::del($this->_mailingId); + CRM_Mailing_BAO_Mailing::deleteRecord(['id' => $this->_mailingId]); CRM_Core_Session::setStatus(ts('Selected mailing has been deleted.'), ts('Deleted'), 'success'); } elseif ($this->_action & CRM_Core_Action::DISABLE) { diff --git a/CRM/Mailing/Page/Browse.php b/CRM/Mailing/Page/Browse.php index ff8fde09ee2c..501e56e1736f 100644 --- a/CRM/Mailing/Page/Browse.php +++ b/CRM/Mailing/Page/Browse.php @@ -199,7 +199,7 @@ public function run() { CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.')); } - CRM_Mailing_BAO_Mailing::del($this->_mailingId); + CRM_Mailing_BAO_Mailing::deleteRecord(['id' => $this->_mailingId]); CRM_Core_Session::setStatus(ts('Selected mailing has been deleted.'), ts('Deleted'), 'success'); CRM_Utils_System::redirect($context); } diff --git a/CRM/Member/BAO/MembershipBlock.php b/CRM/Member/BAO/MembershipBlock.php index 6c208c9b4bc6..d89eae0d2a44 100644 --- a/CRM/Member/BAO/MembershipBlock.php +++ b/CRM/Member/BAO/MembershipBlock.php @@ -24,6 +24,7 @@ class CRM_Member_BAO_MembershipBlock extends CRM_Member_DAO_MembershipBlock { * @return CRM_Member_DAO_MembershipBlock */ public static function create($params) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return self::writeRecord($params); } @@ -35,6 +36,7 @@ public static function create($params) { * @return bool */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return (bool) self::deleteRecord(['id' => $id]); } diff --git a/CRM/Member/BAO/MembershipPayment.php b/CRM/Member/BAO/MembershipPayment.php index a87adb5f43f3..ae949586bd01 100644 --- a/CRM/Member/BAO/MembershipPayment.php +++ b/CRM/Member/BAO/MembershipPayment.php @@ -81,6 +81,7 @@ public static function create($params) { * @return bool */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return (bool) self::deleteRecord(['id' => $id]); } diff --git a/CRM/Member/BAO/MembershipStatus.php b/CRM/Member/BAO/MembershipStatus.php index 5f02f8c598e4..7c791d5812fa 100644 --- a/CRM/Member/BAO/MembershipStatus.php +++ b/CRM/Member/BAO/MembershipStatus.php @@ -151,6 +151,7 @@ public static function getMembershipStatus($membershipStatusId) { * @throws CRM_Core_Exception */ public static function del($membershipStatusId) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); static::deleteRecord(['id' => $membershipStatusId]); } diff --git a/CRM/Member/BAO/MembershipType.php b/CRM/Member/BAO/MembershipType.php index 59e52c960ba7..789eebe74dd1 100644 --- a/CRM/Member/BAO/MembershipType.php +++ b/CRM/Member/BAO/MembershipType.php @@ -123,6 +123,7 @@ public static function flush() { * @return bool */ public static function del($membershipTypeId) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); try { static::deleteRecord(['id' => $membershipTypeId]); return TRUE; diff --git a/CRM/Member/Form/MembershipBlock.php b/CRM/Member/Form/MembershipBlock.php index a7a3abfac894..60ed1248bb2e 100644 --- a/CRM/Member/Form/MembershipBlock.php +++ b/CRM/Member/Form/MembershipBlock.php @@ -151,7 +151,7 @@ public function buildQuickForm() { //CRM-15573 if (!empty($params['id'])) { $params['membership_types'] = serialize($membershipRequired); - CRM_Member_BAO_MembershipBlock::create($params); + CRM_Member_BAO_MembershipBlock::writeRecord($params); } $this->add('hidden', "mem_price_field_id", '', ['id' => "mem_price_field_id"]); $this->assign('is_recur', $isRecur); diff --git a/CRM/Member/Form/MembershipStatus.php b/CRM/Member/Form/MembershipStatus.php index 3791cbeaf394..967e81bfd268 100644 --- a/CRM/Member/Form/MembershipStatus.php +++ b/CRM/Member/Form/MembershipStatus.php @@ -150,7 +150,7 @@ public function buildQuickForm() { public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { try { - CRM_Member_BAO_MembershipStatus::del($this->_id); + CRM_Member_BAO_MembershipStatus::deleteRecord(['id' => $this->_id]); } catch (CRM_Core_Exception $e) { CRM_Core_Error::statusBounce($e->getMessage(), NULL, ts('Delete Failed')); diff --git a/CRM/Member/Form/MembershipType.php b/CRM/Member/Form/MembershipType.php index da1ee84059b0..686e2f36f9cf 100644 --- a/CRM/Member/Form/MembershipType.php +++ b/CRM/Member/Form/MembershipType.php @@ -383,7 +383,7 @@ public static function formRule($params) { public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { try { - CRM_Member_BAO_MembershipType::del($this->_id); + CRM_Member_BAO_MembershipType::deleteRecord(['id' => $this->_id]); } catch (CRM_Core_Exception $e) { CRM_Core_Error::statusBounce($e->getMessage(), NULL, ts('Membership Type Not Deleted')); diff --git a/CRM/Pledge/BAO/PledgePayment.php b/CRM/Pledge/BAO/PledgePayment.php index 4c9e98bbf709..fc00d8f7ac33 100644 --- a/CRM/Pledge/BAO/PledgePayment.php +++ b/CRM/Pledge/BAO/PledgePayment.php @@ -201,6 +201,7 @@ public static function retrieve($params, &$defaults) { * @return bool */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return (bool) self::deleteRecord(['id' => $id]); } @@ -228,7 +229,7 @@ public static function deletePayments($id) { if ($payment->contribution_id) { CRM_Contribute_BAO_Contribution::deleteContribution($payment->contribution_id); } - self::del($payment->id); + self::deleteRecord(['id' => $payment->id]); } } diff --git a/CRM/Price/BAO/PriceFieldValue.php b/CRM/Price/BAO/PriceFieldValue.php index ae00626f9f03..dd614637cd20 100644 --- a/CRM/Price/BAO/PriceFieldValue.php +++ b/CRM/Price/BAO/PriceFieldValue.php @@ -223,6 +223,7 @@ public static function deleteValues($fieldId) { * @return bool */ public static function del($id) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return (bool) self::deleteRecord(['id' => $id]); } diff --git a/CRM/Price/Form/Option.php b/CRM/Price/Form/Option.php index 5aa3b3687b14..f273826335ba 100644 --- a/CRM/Price/Form/Option.php +++ b/CRM/Price/Form/Option.php @@ -320,9 +320,12 @@ public function postProcess() { 'label', 'id' ); - if (CRM_Price_BAO_PriceFieldValue::del($this->_oid)) { + try { + CRM_Price_BAO_PriceFieldValue::deleteRecord(['id' => $this->_oid]); CRM_Core_Session::setStatus(ts('%1 option has been deleted.', [1 => $label]), ts('Record Deleted'), 'success'); } + catch (CRM_Core_Exception $e) { + } return NULL; } else { diff --git a/CRM/Report/BAO/ReportInstance.php b/CRM/Report/BAO/ReportInstance.php index 930b44aad154..1554cc0cce25 100644 --- a/CRM/Report/BAO/ReportInstance.php +++ b/CRM/Report/BAO/ReportInstance.php @@ -223,6 +223,7 @@ public static function &create(&$params) { * @return mixed */ public static function del($id = NULL) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); self::deleteRecord(['id' => $id]); return 1; } @@ -325,7 +326,7 @@ public static function doFormDelete($instanceId, $bounceTo = 'civicrm/report/lis 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 c4a8f659458a..af5c12e4e3f4 100644 --- a/CRM/Report/Form/Register.php +++ b/CRM/Report/Form/Register.php @@ -158,7 +158,7 @@ public static function formRule($fields, $files, $self) { 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/CRM/Tag/Form/Edit.php b/CRM/Tag/Form/Edit.php index 71fe9e8b4795..09d38c00f06f 100644 --- a/CRM/Tag/Form/Edit.php +++ b/CRM/Tag/Form/Edit.php @@ -165,7 +165,7 @@ public function postProcess() { $deleted = 0; $tag = civicrm_api3('tag', 'getsingle', ['id' => $this->_id[0]]); foreach ($this->_id as $id) { - if (CRM_Core_BAO_Tag::del($id)) { + if (CRM_Core_BAO_Tag::deleteRecord(['id' => $id])) { $deleted++; } } diff --git a/CRM/UF/Form/Field.php b/CRM/UF/Form/Field.php index 78c5978d652f..03d583fa903b 100644 --- a/CRM/UF/Form/Field.php +++ b/CRM/UF/Form/Field.php @@ -482,7 +482,7 @@ public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { $fieldValues = ['uf_group_id' => $this->_gid]; CRM_Utils_Weight::delWeight('CRM_Core_DAO_UFField', $this->_id, $fieldValues); - $deleted = CRM_Core_BAO_UFField::del($this->_id); + $deleted = CRM_Core_BAO_UFField::deleteRecord(['id' => $this->_id]); //update group_type every time. CRM-3608 if ($this->_gid && $deleted) { diff --git a/CRM/UF/Form/Group.php b/CRM/UF/Form/Group.php index 454a019c5982..87814ab22e7c 100644 --- a/CRM/UF/Form/Group.php +++ b/CRM/UF/Form/Group.php @@ -350,7 +350,7 @@ public static function formRule($fields, $files, $self) { public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { $title = CRM_Core_BAO_UFGroup::getTitle($this->_id); - CRM_Core_BAO_UFGroup::del($this->_id); + CRM_Core_BAO_UFGroup::deleteRecord(['id' => $this->_id]); CRM_Core_Session::setStatus(ts("Your CiviCRM Profile '%1' has been deleted.", [1 => $title]), ts('Profile Deleted'), 'success'); } elseif ($this->_action & CRM_Core_Action::DISABLE) { diff --git a/api/v3/ActivityType.php b/api/v3/ActivityType.php index 774e9b3101db..6880e6ae7ef2 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); } diff --git a/api/v3/Event.php b/api/v3/Event.php index bfedf30a9cc4..91e8b85d8da6 100644 --- a/api/v3/Event.php +++ b/api/v3/Event.php @@ -167,7 +167,7 @@ function _civicrm_api3_event_get_legacy_support_42(&$event, $event_id) { * @return array */ function civicrm_api3_event_delete($params) { - return CRM_Event_BAO_Event::del($params['id']) ? civicrm_api3_create_success() : civicrm_api3_create_error(ts('Error while deleting event')); + return CRM_Event_BAO_Event::deleteRecord($params) ? civicrm_api3_create_success() : civicrm_api3_create_error(ts('Error while deleting event')); } /** diff --git a/api/v3/MembershipStatus.php b/api/v3/MembershipStatus.php index c4f6fa5f2ed6..5a9dff6dd344 100644 --- a/api/v3/MembershipStatus.php +++ b/api/v3/MembershipStatus.php @@ -110,11 +110,7 @@ function civicrm_api3_membership_status_update($params) { * @throws CRM_Core_Exception */ function civicrm_api3_membership_status_delete($params) { - - $memberStatusDelete = CRM_Member_BAO_MembershipStatus::del($params['id'], TRUE); - if ($memberStatusDelete) { - throw new CRM_Core_Exception($memberStatusDelete['error_message']); - } + CRM_Member_BAO_MembershipStatus::deleteRecord($params); return civicrm_api3_create_success(); } diff --git a/api/v3/OptionValue.php b/api/v3/OptionValue.php index 34a2b00507fb..3c09f146248d 100644 --- a/api/v3/OptionValue.php +++ b/api/v3/OptionValue.php @@ -91,7 +91,7 @@ function _civicrm_api3_option_value_create_spec(&$params) { function civicrm_api3_option_value_delete($params) { // We will get the option group id before deleting so we can flush pseudoconstants. $optionGroupID = civicrm_api('option_value', 'getvalue', ['version' => 3, 'id' => $params['id'], 'return' => 'option_group_id']); - $result = CRM_Core_BAO_OptionValue::del($params['id']); + $result = CRM_Core_BAO_OptionValue::deleteRecord($params); if ($result) { civicrm_api('option_value', 'getfields', ['version' => 3, 'cache_clear' => 1, 'option_group_id' => $optionGroupID]); return civicrm_api3_create_success(); diff --git a/api/v3/PledgePayment.php b/api/v3/PledgePayment.php index 27795e9795f4..9af4316443cc 100644 --- a/api/v3/PledgePayment.php +++ b/api/v3/PledgePayment.php @@ -81,10 +81,11 @@ function _civicrm_api3_pledge_payment_create_spec(&$params) { */ function civicrm_api3_pledge_payment_delete($params) { - if (CRM_Pledge_BAO_PledgePayment::del($params['id'])) { + try { + CRM_Pledge_BAO_PledgePayment::deleteRecord($params); return civicrm_api3_create_success(['id' => $params['id']], $params, 'PledgePayment', 'delete'); } - else { + catch (CRM_Core_Exception $e) { return civicrm_api3_create_error('Could not delete payment'); } } diff --git a/api/v3/Relationship.php b/api/v3/Relationship.php index f1f7664beeb1..22116ef552d8 100644 --- a/api/v3/Relationship.php +++ b/api/v3/Relationship.php @@ -69,7 +69,7 @@ function civicrm_api3_relationship_delete($params) { return civicrm_api3_create_error('Relationship id is not valid'); } else { - $relationBAO->del($params['id']); + $relationBAO::deleteRecord(['id' => $params['id']]); return civicrm_api3_create_success('Deleted relationship successfully'); } } diff --git a/api/v3/UFField.php b/api/v3/UFField.php index 0ac6b070d291..526cc49faca4 100644 --- a/api/v3/UFField.php +++ b/api/v3/UFField.php @@ -77,7 +77,7 @@ function civicrm_api3_uf_field_delete($params) { throw new CRM_Core_Exception('Invalid value for field_id.'); } - $result = CRM_Core_BAO_UFField::del($fieldId); + $result = CRM_Core_BAO_UFField::deleteRecord(['id' => $fieldId]); $fieldsType = CRM_Core_BAO_UFGroup::calculateGroupType($ufGroupId, TRUE); CRM_Core_BAO_UFGroup::updateGroupTypes($ufGroupId, $fieldsType); diff --git a/tests/phpunit/CRM/Activity/Form/ActivityTest.php b/tests/phpunit/CRM/Activity/Form/ActivityTest.php index 9a2b84ca7545..a9c0e912dbc2 100644 --- a/tests/phpunit/CRM/Activity/Form/ActivityTest.php +++ b/tests/phpunit/CRM/Activity/Form/ActivityTest.php @@ -106,7 +106,7 @@ public function testActivityDelete() { 'repetition_frequency_interval' => 1, 'start_action_offset' => $numberOfRepeatingActivitiesToCreate - 1, ]; - $actionScheduleBao = CRM_Core_BAO_ActionSchedule::add($actionScheduleParams); + $actionScheduleBao = CRM_Core_BAO_ActionSchedule::writeRecord($actionScheduleParams); // Create the activity's repeats. $recurringEntityBao = new CRM_Core_BAO_RecurringEntity(); diff --git a/tests/phpunit/CRM/Contact/BAO/ContactType/ContactTypeTest.php b/tests/phpunit/CRM/Contact/BAO/ContactType/ContactTypeTest.php index 6c266845b9d2..59642a21228e 100644 --- a/tests/phpunit/CRM/Contact/BAO/ContactType/ContactTypeTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ContactType/ContactTypeTest.php @@ -353,7 +353,7 @@ public function testAdd() { $this->assertEquals($result->name, $params['name']); $this->assertEquals($result->parent_id, $params['parent_id']); $this->assertEquals($result->is_active, $params['is_active']); - CRM_Contact_BAO_ContactType::del($result->id); + CRM_Contact_BAO_ContactType::deleteRecord(['id' => $result->id]); $params = [ 'label' => 'householdSubType', @@ -366,7 +366,7 @@ public function testAdd() { $this->assertEquals($result->name, $params['name']); $this->assertEquals($result->parent_id, $params['parent_id']); $this->assertEquals($result->is_active, $params['is_active']); - CRM_Contact_BAO_ContactType::del($result->id); + CRM_Contact_BAO_ContactType::deleteRecord(['id' => $result->id]); } /** @@ -429,12 +429,4 @@ public function testDel() { $this->assertEquals(FALSE, in_array($subtype->name, $result, TRUE)); } - /** - * Test del() with invalid data - */ - public function testDelInvalid() { - $del = CRM_Contact_BAO_ContactType::del(NULL); - $this->assertEquals($del, FALSE); - } - } diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php index 15cd1eb13313..bd2d5eb9b78b 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php @@ -397,7 +397,7 @@ public function testAddPremium() { $this->assertEquals($contributionProduct->product_id, $premium->id, 'Check for Product id .'); //Delete Product - CRM_Contribute_BAO_Product::del($premium->id); + CRM_Contribute_BAO_Product::deleteRecord(['id' => $premium->id]); $this->assertDBNull('CRM_Contribute_DAO_Product', $premium->name, 'id', 'name', 'Database check for deleted Product.' ); diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionTypeTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionTypeTest.php index dd36ab2d65de..fe9bce3f1cb6 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionTypeTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionTypeTest.php @@ -34,8 +34,7 @@ public function testAdd() { 'is_deductible' => 0, 'is_active' => 1, ]; - $ids = []; - $contributionType = CRM_Financial_BAO_FinancialType::add($params, $ids); + $contributionType = CRM_Financial_BAO_FinancialType::writeRecord($params); $result = $this->assertDBNotNull('CRM_Financial_BAO_FinancialType', $contributionType->id, 'name', 'id', @@ -54,8 +53,7 @@ public function testSetIsActive() { 'is_deductible' => 0, 'is_active' => 1, ]; - $ids = []; - $contributionType = CRM_Financial_BAO_FinancialType::add($params, $ids); + $contributionType = CRM_Financial_BAO_FinancialType::writeRecord($params); $result = CRM_Financial_BAO_FinancialType::setIsActive($contributionType->id, 0); $this->assertEquals($result, TRUE, 'Verify financial type record updation for is_active.'); diff --git a/tests/phpunit/CRM/Contribute/BAO/ProductTest.php b/tests/phpunit/CRM/Contribute/BAO/ProductTest.php index f242ed60858f..e630e3570622 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ProductTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ProductTest.php @@ -99,7 +99,7 @@ public function testDel() { ]; $product = CRM_Contribute_BAO_Product::create($params); - CRM_Contribute_BAO_Product::del($product->id); + CRM_Contribute_BAO_Product::deleteRecord(['id' => $product->id]); $params = ['id' => $product->id]; $defaults = []; diff --git a/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php b/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php index 83a9d47ccc6f..b9076c26cc96 100644 --- a/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php +++ b/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php @@ -1896,7 +1896,7 @@ public function testContactModifiedAnniversary(): void { $modifiedDate = $this->callAPISuccess('Contact', 'getvalue', ['id' => $contact['id'], 'return' => 'modified_date']); $actionSchedule = $this->createScheduleFromFixtures('sched_contact_mod_anniversary'); $actionSchedule['effective_start_date'] = date('Y-m-d H:i:s', strtotime($contact['values'][$contact['id']]['modified_date'])); - $actionScheduleDao = CRM_Core_BAO_ActionSchedule::add($actionSchedule); + $actionScheduleDao = CRM_Core_BAO_ActionSchedule::writeRecord($actionSchedule); $this->assertCronRuns([ [ // On some random day, no email. @@ -2020,7 +2020,7 @@ public function testMembershipOnMultipleReminder(): void { $actionScheduleAfter['effective_end_date'] = '2012-06-16 02:00:00'; $actionScheduleBefore['entity_value'] = $actionScheduleOn['entity_value'] = $actionScheduleAfter['entity_value'] = $membership['membership_type_id']; foreach (['actionScheduleBefore', 'actionScheduleOn', 'actionScheduleAfter'] as $value) { - $$value = CRM_Core_BAO_ActionSchedule::add($$value); + $$value = CRM_Core_BAO_ActionSchedule::writeRecord($$value); } $this->assertCronRuns( @@ -2546,7 +2546,7 @@ public function testRepetitionFrequencyUnit(): void { $actionScheduleParams['entity_value'] = $membershipType->id; $actionScheduleParams['repetition_frequency_unit'] = $interval_unit; $actionScheduleParams['repetition_frequency_interval'] = 2; - $actionSchedule = CRM_Core_BAO_ActionSchedule::add($actionScheduleParams); + $actionSchedule = CRM_Core_BAO_ActionSchedule::writeRecord($actionScheduleParams); $beforeEndDate = $this->createModifiedDateTime($membershipEndDate, '-1 day'); $beforeFirstUnit = $this->createModifiedDateTime($membershipEndDate, "+1 $interval_unit"); $afterFirstUnit = $this->createModifiedDateTime($membershipEndDate, "+2 $interval_unit"); diff --git a/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php b/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php index effa449831f4..9b9ef44e3477 100644 --- a/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php +++ b/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php @@ -87,7 +87,7 @@ private function createActionSchedule($entity_id, $entity_table) { "start_action_condition" => "monday,tuesday,wednesday,thursday,friday,saturday", "start_action_offset" => "2", ]; - $actionScheduleObj = CRM_Core_BAO_ActionSchedule::add($params); + $actionScheduleObj = CRM_Core_BAO_ActionSchedule::writeRecord($params); return $actionScheduleObj; } diff --git a/tests/phpunit/CRM/Core/BAO/UFGroupTest.php b/tests/phpunit/CRM/Core/BAO/UFGroupTest.php index d753b34072eb..d320f9f051a8 100644 --- a/tests/phpunit/CRM/Core/BAO/UFGroupTest.php +++ b/tests/phpunit/CRM/Core/BAO/UFGroupTest.php @@ -61,7 +61,7 @@ public function testPreHookIsCalledForDelete() { ]; $ufGroup = CRM_Core_BAO_UFGroup::add($params); $ufGroupID = $ufGroup->id; - $ufGroup = CRM_Core_BAO_UFGroup::del($ufGroupID); + $ufGroup = CRM_Core_BAO_UFGroup::deleteRecord(['id' => $ufGroupID]); // Assert that pre hook implemntation was called for delete op. $systemLogCount = $this->callAPISuccess('SystemLog', 'getcount', [ @@ -95,7 +95,7 @@ public function testPostHookIsCalledForDelete() { ]; $ufGroup = CRM_Core_BAO_UFGroup::add($params); $ufGroupID = $ufGroup->id; - $ufGroup = CRM_Core_BAO_UFGroup::del($ufGroupID); + $ufGroup = CRM_Core_BAO_UFGroup::deleteRecord(['id' => $ufGroupID]); // Assert that pre hook implemntation was called for delete op. $systemLogCount = $this->callAPISuccess('SystemLog', 'getcount', [ diff --git a/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php b/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php index 298415a094e7..699d07b6c765 100644 --- a/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php +++ b/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php @@ -33,8 +33,7 @@ public function testAdd() { 'is_deductible' => 0, 'is_active' => 1, ]; - $ids = []; - $financialAccount = CRM_Financial_BAO_FinancialAccount::add($params, $ids); + $financialAccount = CRM_Financial_BAO_FinancialAccount::writeRecord($params); $result = $this->assertDBNotNull( 'CRM_Financial_BAO_FinancialAccount', @@ -56,8 +55,8 @@ public function testRetrieve() { 'is_deductible' => 0, 'is_active' => 1, ]; - $ids = $defaults = []; - CRM_Financial_BAO_FinancialAccount::add($params); + $defaults = []; + CRM_Financial_BAO_FinancialAccount::writeRecord($params); $result = CRM_Financial_BAO_FinancialAccount::retrieve($params, $defaults); @@ -73,8 +72,7 @@ public function testSetIsActive() { 'is_deductible' => 0, 'is_active' => 1, ]; - $ids = []; - $financialAccount = CRM_Financial_BAO_FinancialAccount::add($params, $ids); + $financialAccount = CRM_Financial_BAO_FinancialAccount::writeRecord($params); $result = CRM_Financial_BAO_FinancialAccount::setIsActive($financialAccount->id, 0); $this->assertEquals($result, TRUE, 'Verify financial account record updation for is_active.'); @@ -99,7 +97,7 @@ public function testDel() { 'is_deductible' => 0, 'is_active' => 1, ]; - $financialAccount = CRM_Financial_BAO_FinancialAccount::add($params); + $financialAccount = CRM_Financial_BAO_FinancialAccount::writeRecord($params); CRM_Financial_BAO_FinancialAccount::del($financialAccount->id); $params = ['id' => $financialAccount->id]; @@ -149,8 +147,7 @@ public function testGetAccountingCode() { 'is_reserved' => 0, ]; - $ids = []; - $financialType = CRM_Financial_BAO_FinancialType::add($params, $ids); + $financialType = CRM_Financial_BAO_FinancialType::writeRecord($params); $financialAccountid = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', 'Donations', 'id', 'name'); CRM_Core_DAO::setFieldValue('CRM_Financial_DAO_FinancialAccount', $financialAccountid, 'accounting_code', '4800'); $accountingCode = CRM_Financial_BAO_FinancialAccount::getAccountingCode($financialType->id); diff --git a/tests/phpunit/CRM/Financial/BAO/FinancialItemTest.php b/tests/phpunit/CRM/Financial/BAO/FinancialItemTest.php index d39eeb58a7f8..86226a850977 100644 --- a/tests/phpunit/CRM/Financial/BAO/FinancialItemTest.php +++ b/tests/phpunit/CRM/Financial/BAO/FinancialItemTest.php @@ -185,7 +185,7 @@ public function testCreateEntityTrxn(): CRM_Financial_DAO_EntityFinancialTrxn { ]; $amount = 200; - $financialAccount = CRM_Financial_BAO_FinancialAccount::add($fParams); + $financialAccount = CRM_Financial_BAO_FinancialAccount::writeRecord($fParams); $financialTrxn = new CRM_Financial_DAO_FinancialTrxn(); $financialTrxn->to_financial_account_id = $financialAccount->id; $financialTrxn->total_amount = $amount; diff --git a/tests/phpunit/CRM/Financial/BAO/FinancialTypeAccountTest.php b/tests/phpunit/CRM/Financial/BAO/FinancialTypeAccountTest.php index 29211640a4f4..43ded2fa2372 100644 --- a/tests/phpunit/CRM/Financial/BAO/FinancialTypeAccountTest.php +++ b/tests/phpunit/CRM/Financial/BAO/FinancialTypeAccountTest.php @@ -132,11 +132,11 @@ public function createFinancialAccount($financialAccountType, $relationType = NU 'is_reserved' => 0, 'financial_account_type_id' => array_search($financialAccountType, $financialAccountTypes), ]; - $financialAccount = CRM_Financial_BAO_FinancialAccount::add($params); + $financialAccount = CRM_Financial_BAO_FinancialAccount::writeRecord($params); $financialType = $financialAccountType = NULL; if ($relationType) { $params['name'] = 'test_financialType1'; - $financialType = CRM_Financial_BAO_FinancialType::add($params); + $financialType = CRM_Financial_BAO_FinancialType::writeRecord($params); $financialParams = [ 'entity_table' => 'civicrm_financial_type', 'entity_id' => $financialType->id, diff --git a/tests/phpunit/CRM/Member/BAO/MembershipLogTest.php b/tests/phpunit/CRM/Member/BAO/MembershipLogTest.php index 3f1aa6d8d48c..d0ebb5479f99 100644 --- a/tests/phpunit/CRM/Member/BAO/MembershipLogTest.php +++ b/tests/phpunit/CRM/Member/BAO/MembershipLogTest.php @@ -116,7 +116,7 @@ public function tearDown(): void { */ public function testDel() { list($contactID, $membershipID) = $this->setupMembership(); - CRM_Member_BAO_MembershipLog::del($membershipID); + CRM_Member_BAO_MembershipLog::deleteRecord(['id' => $membershipID]); $this->assertDBNull('CRM_Member_BAO_MembershipLog', $membershipID, 'membership_id', 'id', 'Database check for deleted membership log.' ); diff --git a/tests/phpunit/CRM/Member/BAO/MembershipStatusTest.php b/tests/phpunit/CRM/Member/BAO/MembershipStatusTest.php index af78ef042b6b..cf1dd5b1f406 100644 --- a/tests/phpunit/CRM/Member/BAO/MembershipStatusTest.php +++ b/tests/phpunit/CRM/Member/BAO/MembershipStatusTest.php @@ -105,7 +105,7 @@ public function testDel() { $params = ['name' => 'testStatus', 'is_active' => 1]; $membershipID = $this->callAPISuccess('MembershipStatus', 'create', $params)['id']; - CRM_Member_BAO_MembershipStatus::del($membershipID); + CRM_Member_BAO_MembershipStatus::deleteRecord(['id' => $membershipID]); $defaults = []; $result = CRM_Member_BAO_MembershipStatus::retrieve($params, $defaults); $this->assertEquals($result === NULL, TRUE, 'Verify membership status record deletion.'); diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index ae87412c1d09..b9a4a5ffa674 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -556,18 +556,6 @@ public function createTestEntity() { return $entity = $this->callAPISuccess($this->entity, 'create', $this->params); } - /** - * @param int $contactTypeId - * - * @throws Exception - */ - public function contactTypeDelete($contactTypeId) { - $result = CRM_Contact_BAO_ContactType::del($contactTypeId); - if (!$result) { - throw new Exception('Could not delete contact type'); - } - } - /** * @param array $params *