[REF] Stop passing contribution into completeOrder, id is enough
authoreileen <emcnaughton@wikimedia.org>
Tue, 9 Feb 2021 20:07:10 +0000 (09:07 +1300)
committereileen <emcnaughton@wikimedia.org>
Tue, 9 Feb 2021 20:07:10 +0000 (09:07 +1300)
CRM/Contribute/BAO/Contribution.php
CRM/Core/Payment/AuthorizeNetIPN.php
CRM/Core/Payment/BaseIPN.php
CRM/Core/Payment/PayPalIPN.php
CRM/Core/Payment/PayPalProIPN.php
CRM/Event/Form/Task/Batch.php
api/v3/Contribution.php

index a268e255f86cdc96cd54ec304f33a4546f1bfa13..5285b47ec40ee10fa8a18919cf4777be6f8d5bfb 100644 (file)
@@ -4182,7 +4182,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
    *
    * @param array $input
    * @param array $ids
-   * @param \CRM_Contribute_BAO_Contribution $contribution
+   * @param int|null $contributionID
    * @param bool $isPostPaymentCreate
    *   Is this being called from the payment.create api. If so the api has taken care of financial entities.
    *   Note that our goal is that this would only ever be called from payment.create and never handle financials (only
@@ -4193,7 +4193,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
    * @throws \CRM_Core_Exception
    * @throws \CiviCRM_API3_Exception
    */
-  public static function completeOrder($input, $ids, $contribution, $isPostPaymentCreate = FALSE) {
+  public static function completeOrder($input, $ids, $contributionID, $isPostPaymentCreate = FALSE) {
     $transaction = new CRM_Core_Transaction();
     // @todo see if we even need this - it's used further down to create an activity
     // but the BAO layer should create that - we just need to add a test to cover it & can
@@ -4203,7 +4203,6 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
 
     // Unset ids just to make it clear it's not used again.
     unset($ids);
-    $contributionID = !empty($contribution->id) ? (int) $contribution->id : NULL;
 
     $inputContributionWhiteList = [
       'fee_amount',
index 2d6d571349b1dfc3f385d55cae5780ce2da837a7..42a744a9b467a55fac1a43a0d166231901afc8cc 100644 (file)
@@ -176,7 +176,7 @@ class CRM_Core_Payment_AuthorizeNetIPN extends CRM_Core_Payment_BaseIPN {
     CRM_Contribute_BAO_Contribution::completeOrder($input, [
       'participant' => NULL,
       'contributionRecur' => $recur->id,
-    ], $contribution);
+    ], $contribution->id ?? NULL);
     return $isFirstOrLastRecurringPayment;
   }
 
index a3c5a590607e8be1f0593124b0415d0e2e27133d..9c68336776bca4bce8f8593c718429c5fc738845 100644 (file)
@@ -425,7 +425,7 @@ class CRM_Core_Payment_BaseIPN {
       'related_contact' => $ids['related_contact'] ?? NULL,
       'participant' => !empty($objects['participant']) ? $objects['participant']->id : NULL,
       'contributionRecur' => !empty($objects['contributionRecur']) ? $objects['contributionRecur']->id : NULL,
-    ], $objects['contribution']);
+    ], $objects['contribution']->id ?? NULL);
   }
 
   /**
index 26e1367b17a9e35c44a0bf186044527a11d9c0e6..06888f4fce9933b7a15d1e058d2f61f35e2e5f32 100644 (file)
@@ -225,7 +225,7 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN {
       return;
     }
 
-    CRM_Contribute_BAO_Contribution::completeOrder($input, $ids, $contribution);
+    CRM_Contribute_BAO_Contribution::completeOrder($input, $ids, $contribution->id ?? NULL);
   }
 
   /**
index 87b568654665899a9c937da608522eddf916e00c..4789c67d35d6a8f2b7e1064d865d75b2175001bd 100644 (file)
@@ -351,7 +351,7 @@ class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN {
       return;
     }
 
-    CRM_Contribute_BAO_Contribution::completeOrder($input, $ids, $contribution);
+    CRM_Contribute_BAO_Contribution::completeOrder($input, $ids, $contribution->id ?? NULL);
   }
 
   /**
index c20505cc94e4d750936b3a1708acd4fb057a3a83..19e5a13c92cb8d1bf016559c46d2b6110e53d3e5 100644 (file)
@@ -362,7 +362,7 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task {
       'related_contact' => NULL,
       'participant' => $params['component_id'],
       'contributionRecur' => NULL,
-    ], $contribution);
+    ], $contribution->id ?? NULL);
 
     // reset template values before processing next transactions
     $template->clearTemplateVars();
index a2e112f76e30cde4af08d12749f6a7ba36a339d2..710c6ee7f073c10bd576a88dfe3d69624e458800 100644 (file)
@@ -684,7 +684,7 @@ function _ipn_process_transaction($params, $contribution, $input, $ids) {
     'related_contact' => $ids['related_contact'] ?? NULL,
     'participant' => !empty($objects['participant']) ? $objects['participant']->id : NULL,
     'contributionRecur' => !empty($objects['contributionRecur']) ? $objects['contributionRecur']->id : NULL,
-  ], $objects['contribution'],
+  ], $objects['contribution']->id ?? NULL,
     $params['is_post_payment_create'] ?? NULL);
 }