From 12b44edfa58bf4e72377e71551bec9ff35576547 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Fri, 15 May 2026 12:20:26 +0200 Subject: [PATCH] Always include historical section on forced sends MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "once-per-calendar-month" gate that prevents the historical section from appearing on every regular send also suppressed it on admin "Send now" previews after the first run of the month — making the section silently disappear when re-testing the email. Force-send now bypasses the gate but still updates the last-historical-month stamp, so the real monthly cadence stays intact for cron-driven sends. --- src/Services/NewsletterDispatchService.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Services/NewsletterDispatchService.php b/src/Services/NewsletterDispatchService.php index 569bfd0..8d8662f 100644 --- a/src/Services/NewsletterDispatchService.php +++ b/src/Services/NewsletterDispatchService.php @@ -76,19 +76,26 @@ final class NewsletterDispatchService continue; } - $log[] = $this->dispatchForTree($tree, $module, $now); + $log[] = $this->dispatchForTree($tree, $module, $now, $force); } return $log; } - private function dispatchForTree(Tree $tree, ModuleInterface $module, int $now): string + private function dispatchForTree(Tree $tree, ModuleInterface $module, int $now, bool $force): string { $include_anniversaries = Configuration::includeAnniversaries($tree); $lookahead = Configuration::lookaheadDays($tree); $historical_lookahead = Configuration::historicalLookaheadDays($tree); $current_month = date('Y-m', $now); - $include_historical = Configuration::lastHistoricalMonth($tree) !== $current_month; + + // Normally the historical section only appears on the first + // scheduled send of each calendar month. Forced sends (admin + // hitting "Send now" to preview the newsletter) always include + // it — otherwise re-clicking the button silently strips the + // section after the first run of the month. + $include_historical = $force + || Configuration::lastHistoricalMonth($tree) !== $current_month; $birthdays = $this->event_query_service->upcomingBirthdays($tree, $lookahead); $anniversaries = $include_anniversaries