Always include historical section on forced sends
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.
This commit is contained in:
@@ -76,19 +76,26 @@ final class NewsletterDispatchService
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$log[] = $this->dispatchForTree($tree, $module, $now);
|
$log[] = $this->dispatchForTree($tree, $module, $now, $force);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $log;
|
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);
|
$include_anniversaries = Configuration::includeAnniversaries($tree);
|
||||||
$lookahead = Configuration::lookaheadDays($tree);
|
$lookahead = Configuration::lookaheadDays($tree);
|
||||||
$historical_lookahead = Configuration::historicalLookaheadDays($tree);
|
$historical_lookahead = Configuration::historicalLookaheadDays($tree);
|
||||||
$current_month = date('Y-m', $now);
|
$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);
|
$birthdays = $this->event_query_service->upcomingBirthdays($tree, $lookahead);
|
||||||
$anniversaries = $include_anniversaries
|
$anniversaries = $include_anniversaries
|
||||||
|
|||||||
Reference in New Issue
Block a user