This foreach actually only copes with 1 values. Making that clearer makes it more readable
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'];
}