[REF] Remove unused lines from loadObjects
authoreileen <emcnaughton@wikimedia.org>
Sun, 6 Sep 2020 21:32:41 +0000 (09:32 +1200)
committereileen <emcnaughton@wikimedia.org>
Sun, 6 Sep 2020 21:32:48 +0000 (09:32 +1200)
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

index d99c8c8f80cff9a8b77217557732b5c6db6eecf7..cd8f54f9a3fd86770091ea04927356f70494df53 100644 (file)
@@ -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}<p>";
-      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'])) {