Merge pull request #19059 from eileenmcnaughton/2199_ufgroup_pre_post_hook
authorcolemanw <coleman@civicrm.org>
Fri, 27 Nov 2020 16:30:10 +0000 (11:30 -0500)
committerGitHub <noreply@github.com>
Fri, 27 Nov 2020 16:30:10 +0000 (11:30 -0500)
Remove use of nullArray in delete hooks

19 files changed:
CRM/Batch/BAO/Batch.php
CRM/Campaign/BAO/Campaign.php
CRM/Case/BAO/Case.php
CRM/Contact/BAO/Contact.php
CRM/Contact/BAO/Group.php
CRM/Contact/BAO/Relationship.php
CRM/Contribute/BAO/Contribution.php
CRM/Core/BAO/UFGroup.php
CRM/Event/BAO/Event.php
CRM/Event/BAO/Participant.php
CRM/Grant/BAO/Grant.php
CRM/Mailing/BAO/Mailing.php
CRM/Mailing/BAO/MailingAB.php
CRM/Mailing/BAO/MailingJob.php
CRM/PCP/BAO/PCP.php
CRM/Pledge/BAO/Pledge.php
CRM/Pledge/BAO/PledgeBlock.php
CRM/Utils/Hook.php
Civi/Api4/Generic/Traits/CustomValueActionTrait.php

index 3bb93f140b70980255282f987bf5c2a0d85476ec..e9fea4c3fba1ae3ab68e73a2e16504ec58304905 100644 (file)
@@ -119,7 +119,7 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
    */
   public static function deleteBatch($batchId) {
     // delete entry from batch table
-    CRM_Utils_Hook::pre('delete', 'Batch', $batchId, CRM_Core_DAO::$_nullArray);
+    CRM_Utils_Hook::pre('delete', 'Batch', $batchId);
     $batch = new CRM_Batch_DAO_Batch();
     $batch->id = $batchId;
     $batch->delete();
index 7800cf925d466a00d0bcf6811ffda6545d82a2c6..1aa324805ec5e5765a2d380c05f0b14018a72c82 100644 (file)
@@ -84,7 +84,7 @@ class CRM_Campaign_BAO_Campaign extends CRM_Campaign_DAO_Campaign {
       return FALSE;
     }
 
-    CRM_Utils_Hook::pre('delete', 'Campaign', $id, CRM_Core_DAO::$_nullArray);
+    CRM_Utils_Hook::pre('delete', 'Campaign', $id);
 
     $dao = new CRM_Campaign_DAO_Campaign();
     $dao->id = $id;
index 96a511e69bc9cdacb2b1021b77e7e5862f34fb12..9d7a008c8982c5584b18031d35f83108729d3cc0 100644 (file)
@@ -187,7 +187,7 @@ WHERE civicrm_case.id = %1";
    *   is successful
    */
   public static function deleteCase($caseId, $moveToTrash = FALSE) {
-    CRM_Utils_Hook::pre('delete', 'Case', $caseId, CRM_Core_DAO::$_nullArray);
+    CRM_Utils_Hook::pre('delete', 'Case', $caseId);
 
     //delete activities
     $activities = self::getCaseActivityDates($caseId);
index 8d1095747eca8b887c024fdc162699e959c200d4..fb643f47c30fa23b84a6a5f8bb05264c5ffafe7d 100644 (file)
@@ -3473,9 +3473,9 @@ LEFT JOIN civicrm_address ON ( civicrm_address.contact_id = civicrm_contact.id )
     $obj = new $daoName();
     $obj->id = $id;
     $obj->find();
-    $hookParams = [];
+
     if ($obj->fetch()) {
-      CRM_Utils_Hook::pre('delete', $type, $id, $hookParams);
+      CRM_Utils_Hook::pre('delete', $type, $id);
       $contactId = $obj->contact_id;
       $obj->delete();
     }
index 5861b057571d81d39075582ba5361543015b1c79..138fd9e2d3eddf1b682151b3cca386006d9e9980 100644 (file)
@@ -55,7 +55,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
     if (!$id || !is_numeric($id)) {
       throw new CRM_Core_Exception('Invalid group request attempted');
     }
-    CRM_Utils_Hook::pre('delete', 'Group', $id, CRM_Core_DAO::$_nullArray);
+    CRM_Utils_Hook::pre('delete', 'Group', $id);
 
     $transaction = new CRM_Core_Transaction();
 
index 85a8f53822f191de1eb30b97dae3f8eaf995e5b1..8df124f1c4f33604af94167b6d1988e3da782695 100644 (file)
@@ -717,7 +717,7 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship {
    */
   public static function del($id) {
     // delete from relationship table
-    CRM_Utils_Hook::pre('delete', 'Relationship', $id, CRM_Core_DAO::$_nullArray);
+    CRM_Utils_Hook::pre('delete', 'Relationship', $id);
 
     $relationship = self::clearCurrentEmployer($id, CRM_Core_Action::DELETE);
     $relationship->delete();
index 5545936098061730f7de88e0d937f272ae43bcac..236c1c203e2527d17dcea9de69e6d13a3fc09289 100644 (file)
@@ -1491,7 +1491,7 @@ INNER JOIN  civicrm_contact contact ON ( contact.id = c.contact_id )
    *   $results no of deleted Contribution on success, false otherwise
    */
   public static function deleteContribution($id) {
-    CRM_Utils_Hook::pre('delete', 'Contribution', $id, CRM_Core_DAO::$_nullArray);
+    CRM_Utils_Hook::pre('delete', 'Contribution', $id);
 
     $transaction = new CRM_Core_Transaction();
 
index a79ee24ea5b3ca163459ad61fae5b891b221fbda..fcf582ef6f66d480ece9c6daf75adea9c8e2d580 100644 (file)
@@ -1399,6 +1399,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
    *
    */
   public static function del($id) {
+    CRM_Utils_Hook::pre('delete', 'UFGroup', $id);
+
     //check whether this group contains  any profile fields
     $profileField = new CRM_Core_DAO_UFField();
     $profileField->uf_group_id = $id;
@@ -1416,6 +1418,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
     $group = new CRM_Core_DAO_UFGroup();
     $group->id = $id;
     $group->delete();
+
+    CRM_Utils_Hook::post('delete', 'UFGroup', $id, $group);
     return 1;
   }
 
index 26bb7f276595b880ba16fdb4fea060f71be3b8a8..6adb77093dafebf41f94983e0f2683e5da58b579 100644 (file)
@@ -171,7 +171,7 @@ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event {
       return NULL;
     }
 
-    CRM_Utils_Hook::pre('delete', 'Event', $id, CRM_Core_DAO::$_nullArray);
+    CRM_Utils_Hook::pre('delete', 'Event', $id);
 
     $extends = ['event'];
     $groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, NULL, $extends);
index 9818d888988b4b639230091e81eebb37e8ef2d96..9c726376c9f5de5d8220185cfa172c2253299efa 100644 (file)
@@ -843,7 +843,7 @@ WHERE  civicrm_participant.id = {$participantId}
     if (!$participant->find()) {
       return FALSE;
     }
-    CRM_Utils_Hook::pre('delete', 'Participant', $id, CRM_Core_DAO::$_nullArray);
+    CRM_Utils_Hook::pre('delete', 'Participant', $id);
 
     $transaction = new CRM_Core_Transaction();
 
index e203d546f5585b0b371fe3a7441603de8d5eb630..bc33e04c8070ee600643c5a20239b2c9b24c3b27 100644 (file)
@@ -252,7 +252,7 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
    * @return bool|mixed
    */
   public static function del($id) {
-    CRM_Utils_Hook::pre('delete', 'Grant', $id, CRM_Core_DAO::$_nullArray);
+    CRM_Utils_Hook::pre('delete', 'Grant', $id);
 
     $grant = new CRM_Grant_DAO_Grant();
     $grant->id = $id;
index 8a1e9529096e79d8cee9ad72191469f7686b6299..f28c1f17f5ef71360f1af6e7b109dac2d4d0d387 100644 (file)
@@ -2463,7 +2463,7 @@ LEFT JOIN civicrm_mailing_group g ON g.mailing_id   = m.id
       throw new CRM_Core_Exception(ts('No id passed to mailing del function'));
     }
 
-    CRM_Utils_Hook::pre('delete', 'Mailing', $id, CRM_Core_DAO::$_nullArray);
+    CRM_Utils_Hook::pre('delete', 'Mailing', $id);
 
     // delete all file attachments
     CRM_Core_BAO_File::deleteEntityFile('civicrm_mailing',
index 7d26a2c1000a2f9f43e615dfdd0a7d5be3befe45..e035ec6962297fba866a793a1256f2cf133293bb 100644 (file)
@@ -61,7 +61,7 @@ class CRM_Mailing_BAO_MailingAB extends CRM_Mailing_DAO_MailingAB {
       throw new CRM_Core_Exception(ts('No id passed to MailingAB del function'));
     }
     CRM_Core_Transaction::create()->run(function () use ($id) {
-      CRM_Utils_Hook::pre('delete', 'MailingAB', $id, CRM_Core_DAO::$_nullArray);
+      CRM_Utils_Hook::pre('delete', 'MailingAB', $id);
 
       $dao = new CRM_Mailing_DAO_MailingAB();
       $dao->id = $id;
index 228406bb99653bc7061edc53635c126afaa566f7..020c65b7e16fc70dabeac638b174b1446c962487 100644 (file)
@@ -1122,7 +1122,7 @@ AND    record_type_id = $targetRecordID
    * @return mixed
    */
   public static function del($id) {
-    CRM_Utils_Hook::pre('delete', 'MailingJob', $id, CRM_Core_DAO::$_nullArray);
+    CRM_Utils_Hook::pre('delete', 'MailingJob', $id);
 
     $jobDAO = new CRM_Mailing_BAO_MailingJob();
     $jobDAO->id = $id;
index 6fdd36d0275380d8eb62600bce4d631c9174aed5..9b6afa3dc58064c5198c99e11fd90f8fee2900f5 100644 (file)
@@ -340,7 +340,7 @@ WHERE pcp.id = %1 AND cc.contribution_status_id = %2 AND cc.is_test = 0";
    *   Campaign page id.
    */
   public static function deleteById($id) {
-    CRM_Utils_Hook::pre('delete', 'Campaign', $id, CRM_Core_DAO::$_nullArray);
+    CRM_Utils_Hook::pre('delete', 'Campaign', $id);
 
     $transaction = new CRM_Core_Transaction();
 
index 9bc13cda3129ec13397964d09e3972e705a993f5..299e3ffa56b0303c593f7f51311d001363163350 100644 (file)
@@ -285,7 +285,7 @@ class CRM_Pledge_BAO_Pledge extends CRM_Pledge_DAO_Pledge {
    * @return mixed
    */
   public static function deletePledge($id) {
-    CRM_Utils_Hook::pre('delete', 'Pledge', $id, CRM_Core_DAO::$_nullArray);
+    CRM_Utils_Hook::pre('delete', 'Pledge', $id);
 
     $transaction = new CRM_Core_Transaction();
 
index a3b80ff7d86102dd78c6140bef42a796ec75e31d..68304860c22e5be0727b5488167affea94320b77 100644 (file)
@@ -93,7 +93,7 @@ class CRM_Pledge_BAO_PledgeBlock extends CRM_Pledge_DAO_PledgeBlock {
    * @return mixed|null
    */
   public static function deletePledgeBlock($id) {
-    CRM_Utils_Hook::pre('delete', 'PledgeBlock', $id, CRM_Core_DAO::$_nullArray);
+    CRM_Utils_Hook::pre('delete', 'PledgeBlock', $id);
 
     $transaction = new CRM_Core_Transaction();
 
index 47233dd4bd7c8bb1d09f5f44803b3311ec0fd56a..f173abac3bf2955e94aa4e49f799b737de7ddd14 100644 (file)
@@ -339,7 +339,7 @@ abstract class CRM_Utils_Hook {
    * @return null
    *   the return value is ignored
    */
-  public static function pre($op, $objectName, $id, &$params) {
+  public static function pre($op, $objectName, $id, &$params = []) {
     $event = new \Civi\Core\Event\PreEvent($op, $objectName, $id, $params);
     \Civi::dispatcher()->dispatch('hook_civicrm_pre', $event);
     return $event->getReturnValues();
index 2fed2b7f467c08845ddc67fbb9135ce089c522b6..5a7a0e33127607b914774beb577f54b6af635ce9 100644 (file)
@@ -83,7 +83,7 @@ trait CustomValueActionTrait {
     $customTable = CoreUtil::getTableName($this->getEntityName());
     $ids = [];
     foreach ($items as $item) {
-      \CRM_Utils_Hook::pre('delete', $this->getEntityName(), $item['id'], \CRM_Core_DAO::$_nullArray);
+      \CRM_Utils_Hook::pre('delete', $this->getEntityName(), $item['id']);
       \CRM_Utils_SQL_Delete::from($customTable)
         ->where('id = #value')
         ->param('#value', $item['id'])