Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#4441 - Incorrect error "There might be a data problem, contribution id could not be loaded from the line item" #26893

Merged
merged 1 commit into from
Jul 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions CRM/Event/WorkflowMessage/ParticipantTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,23 @@ public function setParticipantID(int $participantID) {
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;
Expand Down