diff --git a/CRM/Contact/Form/Task/PDFTrait.php b/CRM/Contact/Form/Task/PDFTrait.php index 36734bcd8c36..61e4faad36d9 100644 --- a/CRM/Contact/Form/Task/PDFTrait.php +++ b/CRM/Contact/Form/Task/PDFTrait.php @@ -505,7 +505,7 @@ public function formatMessage(&$message) { ], ]; - $htmlMsg = preg_split($newLineOperators['p']['pattern'], ($message ?? '')); + $htmlMsg = preg_split($newLineOperators['p']['pattern'], $message); foreach ($htmlMsg as $k => & $m) { $messages = preg_split($newLineOperators['br']['pattern'], $m); foreach ($messages as $key => & $msg) { diff --git a/tests/phpunit/CRM/Contact/Form/Task/PDFLetterCommonTest.php b/tests/phpunit/CRM/Contact/Form/Task/PDFLetterCommonTest.php index 3e7fd38c6566..9b7974585cf3 100644 --- a/tests/phpunit/CRM/Contact/Form/Task/PDFLetterCommonTest.php +++ b/tests/phpunit/CRM/Contact/Form/Task/PDFLetterCommonTest.php @@ -52,6 +52,7 @@ public function testFilenameIsAssigned(?string $pdfFileName, ?string $activitySu $form = $this->getPDFForm([ 'pdf_file_name' => $pdfFileName, 'subject' => $activitySubject, + 'html_message' => '
', ], [$this->contactId], $isLiveMode); $fileNameAssigned = $this->submitForm($form)['fileName']; $this->assertEquals($expectedFilename, $fileNameAssigned);