From 07310345bf1b3a5bc864a12cd6e7087fd5584558 Mon Sep 17 00:00:00 2001 From: Jon Goldberg Date: Mon, 4 Oct 2021 14:12:59 -0400 Subject: [PATCH] fixes financial#181 - don't crash when displaying recurring contributions whose 'template' has no line items --- CRM/Contribute/BAO/ContributionRecur.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CRM/Contribute/BAO/ContributionRecur.php b/CRM/Contribute/BAO/ContributionRecur.php index b468a8fa37..d7a67001f2 100644 --- a/CRM/Contribute/BAO/ContributionRecur.php +++ b/CRM/Contribute/BAO/ContributionRecur.php @@ -554,7 +554,11 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_id ) unset($overrides['financial_type_id']); } $result = array_merge($templateContribution, $overrides); - $result['line_item'][$order->getPriceSetID()] = $lineItems; + // Line items aren't always written to a contribution, for mystery reasons. + // Checking for their existence prevents $order->getPriceSetID returning NULL. + if ($lineItems) { + $result['line_item'][$order->getPriceSetID()] = $lineItems; + } // If the template contribution was made on-behalf then add the // relevant values to ensure the activity reflects that. $relatedContact = CRM_Contribute_BAO_Contribution::getOnbehalfIds($result['id']); -- 2.25.1