From 9b38c82152aaff3ee379423087791e8b17a03cc6 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 21 Sep 2021 09:15:11 +1200 Subject: [PATCH] [REF] Remove illusion of looping This foreach actually only copes with 1 values. Making that clearer makes it more readable --- CRM/Contact/Form/Task/PDFTrait.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CRM/Contact/Form/Task/PDFTrait.php b/CRM/Contact/Form/Task/PDFTrait.php index fac7333890..890246d840 100644 --- a/CRM/Contact/Form/Task/PDFTrait.php +++ b/CRM/Contact/Form/Task/PDFTrait.php @@ -449,7 +449,8 @@ trait CRM_Contact_Form_Task_PDFTrait { CRM_Core_DAO::executeQuery($query); $documentInfo = CRM_Core_BAO_File::getEntityFile('civicrm_msg_template', $formValues['template']); - foreach ((array) $documentInfo as $info) { + if ($documentInfo) { + $info = reset($documentInfo); [$html_message, $formValues['document_type']] = CRM_Utils_PDF_Document::docReader($info['fullPath'], $info['mime_type']); $formValues['document_file_path'] = $info['fullPath']; } -- 2.25.1