It's not valid to apply the policy `combined-attached` unless you have
exactly 1 activity. The previous code would silently degrade if the
precondition wasn't met. The revision makes the failure clear.
$html[] = $tokenHtml;
}
- $saveToFile = count($activityIds) === 1 && Civi::settings()->get('recordGeneratedLetters') === 'combined-attached';
+ $saveToFile = Civi::settings()->get('recordGeneratedLetters') === 'combined-attached';
if ($saveToFile) {
+ if (count($activityIds) !== 1) {
+ throw new CRM_Core_Exception("When recordGeneratedLetters=combined-attached, there should only be one activity.");
+ }
+
// We need to capture data from various output-generators whose only
// consistent output format is writing to the console (for download).
$tmpFile = tempnam(sys_get_temp_dir(), 'PDFLetterCommon-');