From ec9f8dcd719cd20f6da15e05e3a65b769326cc27 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 14 Feb 2023 19:12:14 -0800 Subject: [PATCH] CiviContribute - Fix warning about 'suppressedEmails' when generating PDF Use-case: * Open and execute "Find Contributions" * Next to a contribution, choose "more > Send receipt" * Make a PDF * Open another tab and view any other page. * There is warning: Notice: Undefined index: suppressedEmails in CRM_Contribute_Form_Task_PDF->postProcess() (line 139 of ..../web/sites/all/modules/civicrm/CRM/Contribute/Form/Task/PDF.php)." Before: * `$pdfElements['suppressedEmails']` is not always returned * $pdfElements['excludeContactIds'] is alsways returned After: * Both are always returned, even if empty --- CRM/Contribute/Form/Task/PDF.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CRM/Contribute/Form/Task/PDF.php b/CRM/Contribute/Form/Task/PDF.php index f2a812cee7..df39acc994 100644 --- a/CRM/Contribute/Form/Task/PDF.php +++ b/CRM/Contribute/Form/Task/PDF.php @@ -244,14 +244,13 @@ AND {$this->_componentClause}"; $pdfElements = []; $pdfElements['details'] = self::getDetails(implode(',', $contribIds)); $excludeContactIds = []; + $suppressedEmails = 0; if (!$isCreatePDF) { $contactDetails = civicrm_api3('Contact', 'get', [ 'return' => ['email', 'do_not_email', 'is_deceased', 'on_hold'], 'id' => ['IN' => $contactIds], 'options' => ['limit' => 0], ])['values']; - $pdfElements['suppressedEmails'] = 0; - $suppressedEmails = 0; foreach ($contactDetails as $id => $values) { if (empty($values['email']) || (empty($params['override_privacy']) && !empty($values['do_not_email'])) @@ -259,11 +258,11 @@ AND {$this->_componentClause}"; || !empty($values['on_hold']) ) { $suppressedEmails++; - $pdfElements['suppressedEmails'] = $suppressedEmails; $excludeContactIds[] = $values['contact_id']; } } } + $pdfElements['suppressedEmails'] = $suppressedEmails; $pdfElements['excludeContactIds'] = $excludeContactIds; return $pdfElements; -- 2.25.1