Skip to content

Better handling for malformed recurrence data #16

@sdunham

Description

@sdunham

Based on the UI you're using to populate Greg event data, it's possible to get into a state where Greg where it throws an exception while trying to calculate recurrences. Addressing things on the UI side is something that should happen, but as a last line of defense Greg shouldn't throw fatal errors when presented with malformed data.

Example: If you set up events with a "Once" frequency which indicates that no recurrence should happen, it can be possible to get an event into a state when Greg still thinks it should calculate recurrences.

STR:

  1. Set up recurring event, including a "recur until" date
  2. Switch this event to a frequency of "Once" (i.e. no recurrence)
  3. If Greg attempts to calculate recurrences for this event, the combination of the non-valid "Once" frequency and a previously-set "recur until" date results in Greg throwing a fatal error

See post_to_calendar_series in greg/src/Event.php for a potential place to address this issue.

Expected behavior

Greg shouldn't throw a fatal error in this case

Actual behavior

Fatal error: Uncaught InvalidArgumentException: The FREQ rule part must be one of the following: SECONDLY, MINUTELY, HOURLY, DAILY, WEEKLY, MONTHLY, YEARLY in /code/wp-content/plugins/greg/vendor/rlanvin/php-rrule/src/RRule.php:244

Steps to reproduce behavior

  1. Set up recurring event, including a "recur until" date
  2. Switch this event to a frequency of "Once" (i.e. no recurrence)
  3. If Greg attempts to calculate recurrences for this event, the combination of the non-valid "Once" frequency and a previously-set "recur until" date results in Greg throwing a fatal error

What version of WordPress/PHP/Timber/Greg are you using?

How did you install Greg? (for example, via git clone, GitHub zip download, Composer/Packagist?)

Metadata

Metadata

Assignees

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