From 2f9882425d1be81252eeb65134df0d795a11f67d Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 29 Sep 2020 10:19:01 +1300 Subject: [PATCH] [REF] Parse ids before sending to single function (minor simplification) Overview ---------------------------------------- Minor simplification - parse ids into valid format & pass them into single, rather than passing them in wrong & 'asking' single to 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/PayPalProIPN.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/CRM/Core/Payment/PayPalProIPN.php b/CRM/Core/Payment/PayPalProIPN.php index 2866c9bdd6..613186cfae 100644 --- a/CRM/Core/Payment/PayPalProIPN.php +++ b/CRM/Core/Payment/PayPalProIPN.php @@ -300,7 +300,11 @@ class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN { // CRM-13737 - am not aware of any reason why payment_date would not be set - this if is a belt & braces $objects['contribution']->receive_date = !empty($input['payment_date']) ? date('YmdHis', strtotime($input['payment_date'])) : $now; - $this->single($input, $ids, $objects, TRUE, $first); + $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, $first); } /** @@ -364,11 +368,7 @@ class CRM_Core_Payment_PayPalProIPN 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); } /** @@ -480,7 +480,11 @@ INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contr return; } } - $this->single($input, $ids, $objects, FALSE, FALSE); + $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, FALSE, FALSE); } catch (CRM_Core_Exception $e) { Civi::log()->debug($e->getMessage()); -- 2.25.1