Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Deprecate unnecessary del() functions #21200

Merged
merged 1 commit into from
Aug 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Deprecate unnecessary del() functions
  • Loading branch information
colemanw committed Aug 22, 2021
commit 67d870c5cf52f5a93d554d3c136596f53ee10e27
4 changes: 2 additions & 2 deletions CRM/ACL/BAO/ACLEntityRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ public static function setIsActive($id, $is_active) {
*
* @param int $entityRoleId
* ID of the EntityRole record to be deleted.
*
* @deprecated
*/
public static function del($entityRoleId) {
return parent::deleteRecord(['id' => $entityRoleId]);
return self::deleteRecord(['id' => $entityRoleId]);
}

}
7 changes: 2 additions & 5 deletions CRM/Badge/BAO/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,10 @@ public static function create(&$params) {
* Delete name labels.
*
* @param int $printLabelId
* ID of the name label to be deleted.
*
* @deprecated
*/
public static function del($printLabelId) {
$printLabel = new CRM_Core_DAO_PrintLabel();
$printLabel->id = $printLabelId;
$printLabel->delete();
self::deleteRecord(['id' => $printLabelId]);
}

/**
Expand Down
20 changes: 7 additions & 13 deletions CRM/Campaign/BAO/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,18 @@ public static function create(&$params) {
* Delete the campaign.
*
* @param int $id
* Id of the campaign.
*
* @return bool|mixed
* @deprecated
* @return bool|int
*/
public static function del($id) {
if (!$id) {
try {
self::deleteRecord(['id' => $id]);
}
catch (CRM_Core_Exception $e) {
return FALSE;
}

CRM_Utils_Hook::pre('delete', 'Campaign', $id);

$dao = new CRM_Campaign_DAO_Campaign();
$dao->id = $id;
$result = $dao->delete();

CRM_Utils_Hook::post('delete', 'Campaign', $id, $dao);

return $result;
return 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is weird to return bool - silly but OK

}

/**
Expand Down
13 changes: 2 additions & 11 deletions CRM/Core/BAO/ActionSchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,20 +213,11 @@ public static function retrieve(&$params, &$values) {
* Delete a Reminder.
*
* @param int $id
* ID of the Reminder to be deleted.
*
* @deprecated
* @throws CRM_Core_Exception
*/
public static function del($id) {
if ($id) {
$dao = new CRM_Core_DAO_ActionSchedule();
$dao->id = $id;
if ($dao->find(TRUE)) {
$dao->delete();
return;
}
}
throw new CRM_Core_Exception(ts('Invalid value passed to delete function.'));
self::deleteRecord(['id' => $id]);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion CRM/Core/BAO/EntityTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ public static function dataExists($params) {
* Delete the tag for a contact.
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
*
* WARNING: Nonstandard params searches by tag_id rather than id!
*/
public static function del(&$params) {
//invoke pre hook
Expand Down
17 changes: 3 additions & 14 deletions CRM/Core/BAO/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,14 @@ public static function setIsActive($id, $is_active) {
* Function to delete scheduled job.
*
* @param $jobID
* ID of the job to be deleted.
*
* @return bool|null
* @deprecated
* @throws CRM_Core_Exception
*/
public static function del($jobID) {
if (!$jobID) {
throw new CRM_Core_Exception(ts('Invalid value passed to delete function.'));
}

$dao = new CRM_Core_DAO_Job();
$dao->id = $jobID;
if (!$dao->find(TRUE)) {
return NULL;
}

if ($dao->delete()) {
return TRUE;
}
self::deleteRecord(['id' => $jobID]);
return TRUE;
}

/**
Expand Down
10 changes: 2 additions & 8 deletions CRM/Core/BAO/UFField.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,11 @@ public static function setIsActive($id, $is_active) {
* Delete the profile Field.
*
* @param int $id
* Field Id.
*
* @deprecated
* @return bool
*
*/
public static function del($id) {
//delete field field
$field = new CRM_Core_DAO_UFField();
$field->id = $id;
$field->delete();
return TRUE;
return (bool) self::deleteRecord(['id' => $id]);
}

/**
Expand Down
15 changes: 3 additions & 12 deletions CRM/Mailing/BAO/MailingJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -1117,20 +1117,11 @@ public static function findPendingTasks($jobId, $medium) {
* Delete the mailing job.
*
* @param int $id
* Mailing Job id.
*
* @return mixed
* @deprecated
* @return bool
*/
public static function del($id) {
CRM_Utils_Hook::pre('delete', 'MailingJob', $id);

$jobDAO = new CRM_Mailing_BAO_MailingJob();
$jobDAO->id = $id;
$result = $jobDAO->delete();

CRM_Utils_Hook::post('delete', 'MailingJob', $jobDAO->id, $jobDAO);

return $result;
return (bool) self::deleteRecord(['id' => $id]);
}

}
11 changes: 2 additions & 9 deletions CRM/Member/BAO/MembershipBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,11 @@ public static function create($params) {
* Delete membership Blocks.
*
* @param int $id
*
* @deprecated
* @return bool
*/
public static function del($id) {
$dao = new CRM_Member_DAO_MembershipBlock();
$dao->id = $id;
$result = FALSE;
if ($dao->find(TRUE)) {
$dao->delete();
$result = TRUE;
}
return $result;
return (bool) self::deleteRecord(['id' => $id]);
}

}
11 changes: 2 additions & 9 deletions CRM/Member/BAO/MembershipPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,11 @@ public static function create($params) {
* Delete membership Payments.
*
* @param int $id
*
* @deprecated
* @return bool
*/
public static function del($id) {
$dao = new CRM_Member_DAO_MembershipPayment();
$dao->id = $id;
$result = FALSE;
if ($dao->find(TRUE)) {
$dao->delete();
$result = TRUE;
}
return $result;
return (bool) self::deleteRecord(['id' => $id]);
}

}
22 changes: 3 additions & 19 deletions CRM/Pledge/BAO/PledgePayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,27 +203,11 @@ public static function retrieve(&$params, &$defaults) {
* Delete pledge payment.
*
* @param int $id
*
* @return int
* pledge payment id
* @deprecated
* @return bool
*/
public static function del($id) {
$payment = new CRM_Pledge_DAO_PledgePayment();
$payment->id = $id;
if ($payment->find()) {
$payment->fetch();

CRM_Utils_Hook::pre('delete', 'PledgePayment', $id, $payment);

$result = $payment->delete();

CRM_Utils_Hook::post('delete', 'PledgePayment', $id, $payment);

return $result;
}
else {
return FALSE;
}
return (bool) self::deleteRecord(['id' => $id]);
}

/**
Expand Down
11 changes: 2 additions & 9 deletions CRM/Price/BAO/PriceFieldValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,19 +217,12 @@ public static function deleteValues($fieldId) {
* Delete the value.
*
* @param int $id
* Id.
*
* @deprecated
* @return bool
*
*/
public static function del($id) {
if (!$id) {
return FALSE;
}

$fieldValueDAO = new CRM_Price_DAO_PriceFieldValue();
$fieldValueDAO->id = $id;
return $fieldValueDAO->delete();
return (bool) self::deleteRecord(['id' => $id]);
}

/**
Expand Down