From 99f76265c5a462cae4fd59d1a8045492719f7811 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 22 Aug 2021 01:21:45 -0400 Subject: [PATCH] EntityBatch - Deprecate del() function --- CRM/Batch/BAO/EntityBatch.php | 9 ++------- CRM/Financial/Page/AJAX.php | 6 +++++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CRM/Batch/BAO/EntityBatch.php b/CRM/Batch/BAO/EntityBatch.php index b37fbb85c4..025a877b8e 100644 --- a/CRM/Batch/BAO/EntityBatch.php +++ b/CRM/Batch/BAO/EntityBatch.php @@ -29,19 +29,14 @@ class CRM_Batch_BAO_EntityBatch extends CRM_Batch_DAO_EntityBatch { /** * Remove entries from entity batch. * @param array|int $params + * @deprecated * @return CRM_Batch_DAO_EntityBatch */ public static function del($params) { if (!is_array($params)) { $params = ['id' => $params]; } - $entityBatch = new CRM_Batch_DAO_EntityBatch(); - $entityId = $params['id'] ?? NULL; - CRM_Utils_Hook::pre('delete', 'EntityBatch', $entityId, $params); - $entityBatch->copyValues($params); - $entityBatch->delete(); - CRM_Utils_Hook::post('delete', 'EntityBatch', $entityBatch->id, $entityBatch); - return $entityBatch; + return self::deleteRecord($params); } } diff --git a/CRM/Financial/Page/AJAX.php b/CRM/Financial/Page/AJAX.php index b14792abce..33e891cb2a 100644 --- a/CRM/Financial/Page/AJAX.php +++ b/CRM/Financial/Page/AJAX.php @@ -479,7 +479,11 @@ class CRM_Financial_Page_AJAX { $updated = CRM_Batch_BAO_EntityBatch::create($params); } else { - $updated = CRM_Batch_BAO_EntityBatch::del($params); + $delete = \Civi\Api4\EntityBatch::delete(FALSE); + foreach ($params as $field => $val) { + $delete->addWhere($field, '=', $val); + } + $updated = $delete->execute()->count(); } } } -- 2.25.1