diff --git a/CRM/Contribute/BAO/ContributionSoft.php b/CRM/Contribute/BAO/ContributionSoft.php index 030b9e8dfce0..e3324e01ae79 100644 --- a/CRM/Contribute/BAO/ContributionSoft.php +++ b/CRM/Contribute/BAO/ContributionSoft.php @@ -588,6 +588,7 @@ public static function formatHonoreeProfileFields($form, $params, $honorId = NUL * * @throws \CRM_Core_Exception * @throws \CiviCRM_API3_Exception + * @throws \API_Exception */ protected static function processPCP($pcp, $contribution) { $pcpId = self::getSoftCreditIds($contribution->id, TRUE); @@ -609,7 +610,7 @@ protected static function processPCP($pcp, $contribution) { $contributionSoft = self::add($softParams); //Send notification to owner for PCP if ($contributionSoft->pcp_id && empty($pcpId)) { - CRM_Contribute_Form_Contribution_Confirm::pcpNotifyOwner($contribution, (array) $contributionSoft); + CRM_Contribute_Form_Contribution_Confirm::pcpNotifyOwner($contribution->id, (array) $contributionSoft); } } //Delete PCP against this contribution and create new on submitted PCP information diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 81a133d6963f..66aea8a55f02 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -15,6 +15,8 @@ * @copyright CiviCRM LLC https://civicrm.org/licensing */ +use Civi\Api4\Contribution; + /** * form to process actions on the group aspect of Custom Data */ @@ -1393,23 +1395,26 @@ public static function processOnBehalfOrganization(&$behalfOrganization, &$conta * * This is used by contribution and also event PCPs. * - * @param object $contribution + * @param int $contributionID * @param array $contributionSoft * Contribution object. * * @throws \API_Exception * @throws \CRM_Core_Exception */ - public static function pcpNotifyOwner($contribution, array $contributionSoft) { + public static function pcpNotifyOwner(int $contributionID, array $contributionSoft): void { $params = ['id' => $contributionSoft['pcp_id']]; + $contribution = Contribution::get(FALSE) + ->addWhere('id', '=', $contributionID) + ->addSelect('receive_date', 'contact_id')->execute()->first(); CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $params, $pcpInfo); $ownerNotifyID = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCPBlock', $pcpInfo['pcp_block_id'], 'owner_notify_id'); $ownerNotifyOption = CRM_Core_PseudoConstant::getName('CRM_PCP_DAO_PCPBlock', 'owner_notify_id', $ownerNotifyID); - if ($ownerNotifyOption != 'no_notifications' && - (($ownerNotifyOption == 'owner_chooses' && + if ($ownerNotifyOption !== 'no_notifications' && + (($ownerNotifyOption === 'owner_chooses' && CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $contributionSoft['pcp_id'], 'is_notify')) || - $ownerNotifyOption == 'all_owners')) { + $ownerNotifyOption === 'all_owners')) { $pcpInfoURL = CRM_Utils_System::url('civicrm/pcp/info', "reset=1&id={$contributionSoft['pcp_id']}", TRUE, NULL, FALSE, TRUE @@ -1417,17 +1422,17 @@ public static function pcpNotifyOwner($contribution, array $contributionSoft) { // set email in the template here if (CRM_Core_BAO_LocationType::getBilling()) { - [$donorName, $email] = CRM_Contact_BAO_Contact_Location::getEmailDetails($contribution->contact_id, + [$donorName, $email] = CRM_Contact_BAO_Contact_Location::getEmailDetails($contribution['contact_id'], FALSE, CRM_Core_BAO_LocationType::getBilling()); } // get primary location email if no email exist( for billing location). if (!$email) { - [$donorName, $email] = CRM_Contact_BAO_Contact_Location::getEmailDetails($contribution->contact_id); + [$donorName, $email] = CRM_Contact_BAO_Contact_Location::getEmailDetails($contribution['contact_id']); } [$ownerName, $ownerEmail] = CRM_Contact_BAO_Contact_Location::getEmailDetails($contributionSoft['contact_id']); $tplParams = [ 'page_title' => $pcpInfo['title'], - 'receive_date' => $contribution->receive_date, + 'receive_date' => $contribution['receive_date'], 'total_amount' => $contributionSoft['amount'], 'donors_display_name' => $donorName, 'donors_email' => $email,