From eb0fd0ce726c565827e10020dde87b3d9c249f09 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 7 Sep 2020 09:32:41 +1200 Subject: [PATCH] [REF] Remove unused lines from loadObjects loadObjects is only called from one place. As we can see the contribution object is always passed in so we don't need to handle the possibility of it being anything other than a BAO (I tweaked the error handling around that line too to make it clearer where it was coming from) --- CRM/Core/Payment/BaseIPN.php | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/CRM/Core/Payment/BaseIPN.php b/CRM/Core/Payment/BaseIPN.php index d99c8c8f80..cd8f54f9a3 100644 --- a/CRM/Core/Payment/BaseIPN.php +++ b/CRM/Core/Payment/BaseIPN.php @@ -92,9 +92,7 @@ class CRM_Core_Payment_BaseIPN { $contribution = new CRM_Contribute_BAO_Contribution(); $contribution->id = $ids['contribution']; if (!$contribution->find(TRUE)) { - CRM_Core_Error::debug_log_message("Could not find contribution record: {$contribution->id} in IPN request: " . print_r($input, TRUE)); - echo "Failure: Could not find contribution record for {$contribution->id}

"; - return FALSE; + throw new CRM_Core_Exception('Failure: Could not find contribution record for ' . (int) $contribution->id, NULL, ['context' => "Could not find contribution record: {$contribution->id} in IPN request: " . print_r($input, TRUE)]); } // make sure contact exists and is valid @@ -159,17 +157,8 @@ class CRM_Core_Payment_BaseIPN { 'echo_error' => 1, ]; } + $contribution = &$objects['contribution']; $ids['paymentProcessor'] = $paymentProcessorID; - if (is_a($objects['contribution'], 'CRM_Contribute_BAO_Contribution')) { - $contribution = &$objects['contribution']; - } - else { - //legacy support - functions are 'used' to be able to pass in a DAO - $contribution = new CRM_Contribute_BAO_Contribution(); - $contribution->id = $ids['contribution'] ?? NULL; - $contribution->find(TRUE); - $objects['contribution'] = &$contribution; - } try { $success = $contribution->loadRelatedObjects($input, $ids); if ($required && empty($contribution->_relatedObjects['paymentProcessor'])) { -- 2.25.1