Skip to content

fix(CalDAV/Backend/PDO): include RDATE instances in lastoccurence - #1689

Open
PhilflowIO wants to merge 1 commit into
sabre-io:masterfrom
PhilflowIO:fix/rdate-lastoccurence
Open

PhilflowIO wants to merge 1 commit into
sabre-io:masterfrom
PhilflowIO:fix/rdate-lastoccurence

Conversation

@PhilflowIO

Copy link
Copy Markdown

Fixes #1688

getDenormalizedData() only ran the EventIterator for events with an RRULE. An event that recurs through RDATE alone got lastoccurence = end of its first instance, so calendarQuery() dropped it in SQL for every later RDATE instance.

Change

  • The RRULE branch's iterator loop moves into a private method, getLastOccurenceOfRecurrence(). RRULE events call it as before.
  • Events without RRULE compute the end of the first instance as before. If they have RDATE, the same method extends lastoccurence; the stored value can only grow compared to today.
  • The loop keeps the latest end instead of the end of the last iterated instance, because RDATE values need not be in chronological order. For RRULE the result is unchanged.
  • NoInstancesException (EXDATE removes every instance) and InvalidDataException (RDATE;VALUE=PERIOD, RDATE PERIOD with TZID doesn't seem to be recognised vobject#601) are caught and the first instance's end is kept, so these objects still store with 201 instead of failing with a 500.

Tests

Added to tests/Sabre/CalDAV/Backend/AbstractPDOTestCase.php:

  • testCreateCalendarObjectRDate (RDATE values out of order)
  • testCreateCalendarObjectRDatePeriod
  • testCreateCalendarObjectRDateNoInstances
  • testCalendarQueryTimeRangeRDate

The first and last fail without the fix. Run on SQLite only; the MySQL and PostgreSQL variants were skipped locally.

Full suite on PHP 8.5.12: 1680 tests, the only errors are the two existing testGetLastModified deprecations (ctype_digit()), same as on master without this change. php-cs-fixer (dry run) and phpstan pass.

Notes

  • The commit cherry-picks cleanly onto 4.7. Baïkal 0.12.1 ships 4.7.1, so a backport would help its users.
  • Existing rows are not recomputed; they pick up the new value when the object is saved again. I left a recompute script out. Happy to add one under bin/ if you want it.
  • I left CHANGELOG.md alone, since it is updated at release time.

getDenormalizedData() only ran the EventIterator for events with an
RRULE. For an event that recurs through RDATE alone, lastoccurence was
set to the end of the first instance, so calendarQuery() filtered out
every later RDATE instance in SQL before the validator saw the object.

Run the same iterator loop for RDATE events and keep the latest end,
since RDATE values do not have to be in chronological order. If the
iterator throws (all instances removed by EXDATE, or RDATE;VALUE=PERIOD,
sabre-io/vobject#601), keep the end of the first instance as before so
such objects can still be stored.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PDO backend: RDATE-only event missing from time-range queries after its first instance

1 participant