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

More del() deprecations in favour of standard deleteRecord() #25006

Merged
merged 1 commit into from
Nov 22, 2022
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
6 changes: 3 additions & 3 deletions CRM/Core/BAO/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ public static function retrieve($params, &$defaults) {
* Id of the extension to be deleted.
*
* @return mixed
*
* @deprecated
*/
public static function del($id) {
$extension = new CRM_Core_DAO_Extension();
$extension->id = $id;
return $extension->delete();
return (bool) static::deleteRecord(['id' => $id]);
}

/**
Expand Down
45 changes: 24 additions & 21 deletions CRM/Core/BAO/UFGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* UF group BAO class.
*/
class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup implements \Civi\Core\HookInterface {

const PUBLIC_VISIBILITY = 1,
ADMIN_VISIBILITY = 2,
Expand Down Expand Up @@ -1400,30 +1400,33 @@ public static function usedByModule($id) {
*
* @return bool
*
* @deprecated
*/
public static function del($id) {
CRM_Utils_Hook::pre('delete', 'UFGroup', $id);
return (bool) static::deleteRecord(['id' => $id]);
}

//check whether this group contains any profile fields
$profileField = new CRM_Core_DAO_UFField();
$profileField->uf_group_id = $id;
$profileField->find();
while ($profileField->fetch()) {
CRM_Core_BAO_UFField::del($profileField->id);
/**
* Callback for hook_civicrm_pre().
* @param \Civi\Core\Event\PreEvent $event
* @throws CRM_Core_Exception
*/
public static function self_hook_civicrm_pre(\Civi\Core\Event\PreEvent $event) {
if ($event->action === 'delete' && $event->id) {
// Check whether this group contains any profile fields
$profileField = new CRM_Core_DAO_UFField();
$profileField->uf_group_id = $event->id;
$profileField->find();
while ($profileField->fetch()) {
CRM_Core_BAO_UFField::deleteRecord(['id' => $profileField->id]);
}

// Delete records from uf join table
// Should probably use a deleteRecord rather than direct delete
$ufJoin = new CRM_Core_DAO_UFJoin();
$ufJoin->uf_group_id = $event->id;
$ufJoin->delete();
}

//delete records from uf join table
$ufJoin = new CRM_Core_DAO_UFJoin();
$ufJoin->uf_group_id = $id;
$ufJoin->delete();

//delete profile group
$group = new CRM_Core_DAO_UFGroup();
$group->id = $id;
$group->delete();

CRM_Utils_Hook::post('delete', 'UFGroup', $id, $group);
return 1;
}

/**
Expand Down
18 changes: 4 additions & 14 deletions CRM/Core/BAO/Website.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static function process($params, $contactID, $skipDelete) {
self::create($values);
}
elseif ($skipDelete && !empty($values['id'])) {
self::del($values['id']);
static::deleteRecord($values);
}
}
}
Expand All @@ -95,21 +95,11 @@ public static function process($params, $contactID, $skipDelete) {
* @param int $id
*
* @return bool
*
* @deprecated
*/
public static function del($id) {
$obj = new self();
$obj->id = $id;
$obj->find();
if ($obj->fetch()) {
$params = [];
CRM_Utils_Hook::pre('delete', 'Website', $id, $params);
$obj->delete();
}
else {
return FALSE;
}
CRM_Utils_Hook::post('delete', 'Website', $id, $obj);
return TRUE;
return (bool) static::deleteRecord(['id' => $id]);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions CRM/Member/BAO/MembershipLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ public static function add($params) {
/**
* Delete membership log record.
*
* @param int $membershipID
* @param int $id
*
* @return mixed
*
* @deprecated
*/
public static function del($membershipID) {
$membershipLog = new CRM_Member_DAO_MembershipLog();
$membershipLog->membership_id = $membershipID;
return $membershipLog->delete();
public static function del($id) {
return (bool) static::deleteRecord(['id' => $id]);
}

/**
Expand Down