From 90fa3b29a736fa0695f78eb3e0d896dd6af7e057 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Fri, 21 Jul 2023 09:44:02 -0400 Subject: [PATCH] fix --- .../WorkflowMessage/ParticipantTrait.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/CRM/Event/WorkflowMessage/ParticipantTrait.php b/CRM/Event/WorkflowMessage/ParticipantTrait.php index 8186f2371b..9ccb56884e 100644 --- a/CRM/Event/WorkflowMessage/ParticipantTrait.php +++ b/CRM/Event/WorkflowMessage/ParticipantTrait.php @@ -96,20 +96,23 @@ trait CRM_Event_WorkflowMessage_ParticipantTrait { if (!$this->getContributionID()) { $lineItem = LineItem::get(FALSE) ->addWhere('entity_table', '=', 'civicrm_participant') - ->addWhere('id', '=', $participantID) + ->addWhere('entity_id', '=', $participantID) ->addSelect('contribution_id') ->execute()->first(); if (!empty($lineItem)) { $this->setContributionID($lineItem['contribution_id']); } - // It might be bad data on the site - let's do a noisy fall back to participant payment - // (the relationship between contribution & participant should be in the line item but - // some integrations might mess this up - if they are not using the order api). - $participantPayment = civicrm_api3('ParticipantPayment', 'get', ['participant_id' => $participantID])['values']; - if (!empty($participantPayment)) { - $participantPayment = reset($participantPayment); - $this->setContributionID((int) $participantPayment['contribution_id']); + else { + // no ts() since this should be rare CRM_Core_Session::setStatus('There might be a data problem, contribution id could not be loaded from the line item'); + // It might be bad data on the site - let's do a noisy fall back to participant payment + // (the relationship between contribution & participant should be in the line item but + // some integrations might mess this up - if they are not using the order api). + $participantPayment = civicrm_api3('ParticipantPayment', 'get', ['participant_id' => $participantID])['values']; + if (!empty($participantPayment)) { + $participantPayment = reset($participantPayment); + $this->setContributionID((int) $participantPayment['contribution_id']); + } } } return $this; -- 2.25.1