Skip to content

Commit

Permalink
[REF] simplify interaction with objects in complete order
Browse files Browse the repository at this point in the history
Per civicrm#18382 this line seems to be heavily tested so
& per the test we can use the 'already calculated value' for payment_processor_id rather than look
it up in yet another place.

This adds a query but in most cases queries can be removed before calling this function as
the various objects are not really accessed anymore (apart from the few lines just above this)
  • Loading branch information
eileenmcnaughton committed Sep 6, 2020
1 parent f412f88 commit 6e8a648
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Civi\Api4\ContributionPage;
use Civi\Api4\ContributionRecur;
use Civi\Api4\Participant;
use Civi\Api4\PaymentProcessor;

/**
*
Expand Down Expand Up @@ -4428,7 +4429,7 @@ public static function completeOrder($input, $ids, $objects, $isPostPaymentCreat
// If paymentProcessor is not set then the payment_instrument_id would not be correct.
// not clear when or if this would occur if you encounter this please fix here & add a unit test.
if (empty($contributionParams['payment_instrument_id']) && isset($contribution->_relatedObjects['paymentProcessor']['payment_instrument_id'])) {
$contributionParams['payment_instrument_id'] = $contribution->_relatedObjects['paymentProcessor']['payment_instrument_id'];
$contributionParams['payment_instrument_id'] = PaymentProcessor::get()->addWhere('id', '=', $paymentProcessorId)->addSelect('payment_instrument_id')->execute()->first()['payment_instrument_id'];
}

if ($recurringContributionID) {
Expand Down

0 comments on commit 6e8a648

Please sign in to comment.