Skip to content

Commit

Permalink
BAO - Noisily deprecate and stop using deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Feb 28, 2023
1 parent 0c7aef5 commit dcd2a57
Show file tree
Hide file tree
Showing 87 changed files with 119 additions and 84 deletions.
6 changes: 3 additions & 3 deletions CRM/Admin/Form/ContactType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion CRM/Admin/Form/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Admin/Form/LocationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Admin/Form/Mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
Expand Down
3 changes: 2 additions & 1 deletion CRM/Admin/Form/MessageTemplates.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Admin/Form/OptionGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion CRM/Admin/Form/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Admin/Form/PaymentProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Admin/Form/RelationshipType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion CRM/Admin/Form/ScheduleReminders.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions CRM/Badge/BAO/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public static function create(&$params) {
* @deprecated
*/
public static function del($printLabelId) {
CRM_Core_Error::deprecatedFunctionWarning('deleteRecord');
self::deleteRecord(['id' => $printLabelId]);
}

Expand Down
2 changes: 1 addition & 1 deletion CRM/Badge/Form/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions CRM/Batch/BAO/EntityBatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
1 change: 1 addition & 0 deletions CRM/Campaign/BAO/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
1 change: 1 addition & 0 deletions CRM/Campaign/BAO/Survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Campaign/Form/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion CRM/Campaign/Form/Petition.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion CRM/Campaign/Form/Survey/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Campaign/Form/Survey/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion CRM/Campaign/Form/SurveyType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
Expand Down
1 change: 1 addition & 0 deletions CRM/Case/BAO/CaseType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand Down
1 change: 1 addition & 0 deletions CRM/Contact/BAO/ContactType.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ public static function getCreateNewList() {
* @return bool
*/
public static function del($contactTypeId) {
CRM_Core_Error::deprecatedFunctionWarning('deleteRecord');
if (!$contactTypeId) {
return FALSE;
}
Expand Down
3 changes: 2 additions & 1 deletion CRM/Contact/BAO/GroupContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

/**
Expand Down
8 changes: 2 additions & 6 deletions CRM/Contact/BAO/RelationshipType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand Down
2 changes: 1 addition & 1 deletion CRM/Contact/Form/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions CRM/Contact/Page/View/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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');
}

Expand Down
5 changes: 2 additions & 3 deletions CRM/Contribute/BAO/ManagePremiums.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

}
1 change: 1 addition & 0 deletions CRM/Contribute/BAO/Premium.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand Down
1 change: 1 addition & 0 deletions CRM/Contribute/BAO/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/Form/ManagePremiums.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href='%1'>Online Contribution page</a>. Please remove it before deleting this Premium.", [1 => CRM_Utils_System::url('civicrm/admin/contribute', 'reset=1')]);
Expand Down
2 changes: 2 additions & 0 deletions CRM/Core/BAO/ActionSchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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]);
}

Expand Down
1 change: 1 addition & 0 deletions CRM/Core/BAO/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,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]);
}

Expand Down
4 changes: 2 additions & 2 deletions CRM/Core/BAO/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -307,7 +307,7 @@ public static function blockDelete($blockName, $params) {
}

$baoString = 'CRM_Core_BAO_' . $name;
$baoString::del($params['id']);
$baoString::deleteRecord($params);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/BAO/CustomField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}

Expand Down
1 change: 1 addition & 0 deletions CRM/Core/BAO/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions CRM/Core/BAO/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand Down
1 change: 1 addition & 0 deletions CRM/Core/BAO/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand Down
1 change: 1 addition & 0 deletions CRM/Core/BAO/IM.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand Down
1 change: 1 addition & 0 deletions CRM/Core/BAO/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions CRM/Core/BAO/LocationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public static function create(&$params) {
* @deprecated
*/
public static function del($locationTypeId) {
CRM_Core_Error::deprecatedFunctionWarning('deleteRecord');
static::deleteRecord(['id' => $locationTypeId]);
}

Expand Down
Loading

0 comments on commit dcd2a57

Please sign in to comment.