From: Eileen McNaughton Date: Mon, 20 Sep 2021 21:15:11 +0000 (+1200) Subject: [REF] Remove illusion of looping X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9b38c82152aaff3ee379423087791e8b17a03cc6;p=civicrm-core.git [REF] Remove illusion of looping This foreach actually only copes with 1 values. Making that clearer makes it more readable --- 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']; }