[REF] Parse ids before sending to single function (minor simplification)
authoreileen <emcnaughton@wikimedia.org>
Mon, 28 Sep 2020 21:14:59 +0000 (10:14 +1300)
committereileen <emcnaughton@wikimedia.org>
Mon, 28 Sep 2020 21:15:03 +0000 (10:15 +1300)
Overview
----------------------------------------
Minor simplification - parse ids into valid format & pass them into single, rather than passing them in wrong & 'asking' singleto parse them

Before
----------------------------------------
parsing of ids into usable array done at the last minute, other values passes around unnecessarily

After
----------------------------------------
parsing done close to the point where they are derived

Technical Details
----------------------------------------

Comments
----------------------------------------

CRM/Core/Payment/PayPalIPN.php

index 2a3616fce072791671aae048c8fc4d745d80514d..c9e35fae42977bd14e6d3da7df46f2d3ff723926 100644 (file)
@@ -206,7 +206,11 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN {
       return;
     }
 
-    $this->single($input, $ids, $objects, TRUE);
+    $this->single($input, [
+      'related_contact' => $ids['related_contact'] ?? NULL,
+      'participant' => !empty($objects['participant']) ? $objects['participant']->id : NULL,
+      'contributionRecur' => !empty($objects['contributionRecur']) ? $objects['contributionRecur']->id : NULL,
+    ], $objects, TRUE);
   }
 
   /**
@@ -248,11 +252,7 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN {
       return;
     }
 
-    CRM_Contribute_BAO_Contribution::completeOrder($input, [
-      'related_contact' => $ids['related_contact'] ?? NULL,
-      'participant' => !empty($objects['participant']) ? $objects['participant']->id : NULL,
-      'contributionRecur' => !empty($objects['contributionRecur']) ? $objects['contributionRecur']->id : NULL,
-    ], $objects);
+    CRM_Contribute_BAO_Contribution::completeOrder($input, $ids, $objects);
   }
 
   /**
@@ -359,7 +359,11 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN {
         Civi::log()->debug('Returning since contribution status is not handled');
         return;
       }
-      $this->single($input, $ids, $objects);
+      $this->single($input, [
+        'related_contact' => $ids['related_contact'] ?? NULL,
+        'participant' => !empty($objects['participant']) ? $objects['participant']->id : NULL,
+        'contributionRecur' => !empty($objects['contributionRecur']) ? $objects['contributionRecur']->id : NULL,
+      ], $objects);
     }
     catch (CRM_Core_Exception $e) {
       Civi::log()->debug($e->getMessage());