Skip to content

Recurring events created via upsert_event show on every day instead of correct day-of-week #199

@chubes4

Description

@chubes4

Bug Description

When a recurring weekly event (e.g., "Monday Night Funk Jam" every Monday) is created via the AI upsert_event handler with a date range spanning multiple weeks, the calendar displays it on every single day in the range — including incorrect days (Tuesdays, Wednesdays, etc.).

Reproduction

  1. Create an event via upsert_event (AI pipeline) with:
    • startDate: "2026-04-06" (Monday)
    • endDate: "2026-05-11" (Monday)
    • occurrenceDates: [] (empty)
  2. View the event on the calendar
  3. Event appears on all 36 days (Apr 6 through May 11) instead of only on Mondays

Root Cause

The DateGrouper::group_events_by_date() logic at inc/Blocks/Calendar/Grouping/DateGrouper.php:88-98:

if ( $has_occurrence_dates ) {
    $event_dates = $occurrence_dates;           // Use explicit dates
} elseif ( $is_multi_day ) {
    $event_dates = MultiDayResolver::get_date_range( ... );  // ALL days in range
} else {
    $event_dates = array( $start_date );        // Single day
}

When occurrenceDates is empty and startDate !== endDate, the event is treated as a continuous multi-day event (like a festival). MultiDayResolver::get_date_range() generates every calendar date between start and end — correct for festivals, wrong for weekly recurring events.

Contrast with Working Approach

The SingleRecurring handler (inc/Steps/EventImport/Handlers/SingleRecurring/SingleRecurring.php) creates one event per occurrence with startDate = endDate (single day), updated weekly by the pipeline. This works correctly.

Affected Event

  • Post ID 163758 on events.extrachill.com: MONDAY NIGHT FUNK JAM at LO-Fi Brewing
  • Created by: upsert_event handler (flow_id 10, pipeline_id 3)
  • startDate: "2026-04-06", endDate: "2026-05-11", occurrenceDates: []
  • Should only appear on 6 Mondays: Apr 6, 13, 20, 27, May 4, 11

Proposed Fix Options

Option A: Fix the upsert path

When the AI EventUpsert creates an event where:

  1. startDate and endDate are different
  2. The span is >7 days
  3. The start and end fall on the same day of week

→ Automatically populate occurrenceDates with each recurrence date instead of treating it as a continuous multi-day range.

Option B: Add a "recurring pattern" attribute

Add a recurrencePattern block attribute (e.g., "weekly:monday") that the DateGrouper can use to expand only the correct days, similar to how iCal RRULE works.

Option C: Guard in DateGrouper

In DateGrouper, detect when a multi-day range spans weeks and the event only occurs on one day-of-week. This is fragile but would catch existing broken events.

Immediate Workaround

Manually set occurrenceDates on the block attributes to the correct dates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions