From 175f6d956cec618e9d76047816f27fa7e073b885 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 21 Sep 2020 12:03:19 +1200 Subject: [PATCH] [REF] Remove unreachable lines The function recur ONLY calls single if first is TRUE. Once we remove first from the if clause we can see it applies if recur is TRUE or if recur is FALSE (or any other variant given we are using truthiness). So the if can go --- CRM/Core/Payment/PayPalIPN.php | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/CRM/Core/Payment/PayPalIPN.php b/CRM/Core/Payment/PayPalIPN.php index d63203a155..0330424e03 100644 --- a/CRM/Core/Payment/PayPalIPN.php +++ b/CRM/Core/Payment/PayPalIPN.php @@ -206,9 +206,7 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { return; } - $this->single($input, $ids, $objects, - TRUE, $first - ); + $this->single($input, $ids, $objects, TRUE); } /** @@ -216,25 +214,19 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { * @param array $ids * @param array $objects * @param bool $recur - * @param bool $first * * @return void * @throws \CRM_Core_Exception * @throws \CiviCRM_API3_Exception */ - public function single($input, $ids, $objects, $recur = FALSE, $first = FALSE) { + public function single($input, $ids, $objects, $recur = FALSE) { $contribution = &$objects['contribution']; // make sure the invoice is valid and matches what we have in the contribution record - if ((!$recur) || ($recur && $first)) { - if ($contribution->invoice_id != $input['invoice']) { - Civi::log()->debug('PayPalIPN: Invoice values dont match between database and IPN request. (ID: ' . $contribution->id . ').'); - echo "Failure: Invoice values dont match between database and IPN request

"; - return; - } - } - else { - $contribution->invoice_id = md5(uniqid(rand(), TRUE)); + if ($contribution->invoice_id != $input['invoice']) { + Civi::log()->debug('PayPalIPN: Invoice values dont match between database and IPN request. (ID: ' . $contribution->id . ').'); + echo "Failure: Invoice values dont match between database and IPN request

"; + return; } if (!$recur) { -- 2.25.1