[REF] Remove illusion of looping
authorEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 20 Sep 2021 21:15:11 +0000 (09:15 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 20 Sep 2021 21:15:11 +0000 (09:15 +1200)
This foreach actually only copes with 1 values. Making that clearer makes it more readable

CRM/Contact/Form/Task/PDFTrait.php

index fac73338907c77e1e0b38c3faf8a4f61eaf98d69..890246d84097c5b09cb16e555d07ccd7694a26eb 100644 (file)
@@ -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'];
       }