diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index d0e0f992e2fd..931e33923b9b 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -2321,42 +2321,42 @@ public function composeMessageArray($input, $ids, $values = [], $returnMessageTe } } + $eventID = isset($ids['event']) ? (int) $ids['event'] : NULL; + $participantID = isset($ids['participant']) ? (int) $ids['participant'] : NULL; + $contributionID = (int) $this->id; + $contactID = (int) $ids['contact']; + $onbehalfDedupeAlert = $ids['onbehalf_dupe_alert'] ?? NULL; + // not sure whether it is possible for this not to be an array - load related contacts loads an array but this code was expecting a string + // the addition of the casting is in case it could get here & be a string. Added in 4.6 - maybe remove later? This AuthorizeNetIPN & PaypalIPN tests hit this + // line having loaded an array + $membershipIDs = !empty($ids['membership']) ? (array) $ids['membership'] : NULL; + unset($ids); + if ($this->_component != 'contribute') { // we are in event mode // make sure event exists and is valid $event = new CRM_Event_BAO_Event(); - $event->id = $ids['event']; - if ($ids['event'] && + $event->id = $eventID; + if ($eventID && !$event->find(TRUE) ) { - throw new CRM_Core_Exception("Could not find event: " . $ids['event']); + throw new CRM_Core_Exception("Could not find event: " . $eventID); } $this->_relatedObjects['event'] = &$event; $participant = new CRM_Event_BAO_Participant(); - $participant->id = $ids['participant']; - if ($ids['participant'] && + $participant->id = $participantID; + if ($participantID && !$participant->find(TRUE) ) { - throw new CRM_Core_Exception("Could not find participant: " . $ids['participant']); + throw new CRM_Core_Exception("Could not find participant: " . $participantID); } $participant->register_date = CRM_Utils_Date::isoToMysql($participant->register_date); $this->_relatedObjects['participant'] = &$participant; } - $eventID = isset($ids['event']) ? (int) $ids['event'] : NULL; - $participantID = isset($ids['participant']) ? (int) $ids['participant'] : NULL; - $contributionID = (int) $this->id; - $contactID = (int) $ids['contact']; - $onbehalfDedupeAlert = $ids['onbehalf_dupe_alert'] ?? NULL; - // not sure whether it is possible for this not to be an array - load related contacts loads an array but this code was expecting a string - // the addition of the casting is in case it could get here & be a string. Added in 4.6 - maybe remove later? This AuthorizeNetIPN & PaypalIPN tests hit this - // line having loaded an array - $membershipIDs = !empty($ids['membership']) ? (array) $ids['membership'] : NULL; - unset($ids); - //not really sure what params might be passed in but lets merge em into values $values = array_merge($this->_gatherMessageValues($values, $eventID, $participantID), $values); $values['is_email_receipt'] = !$returnMessageText;