Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handling for malformed recurrence data #16

Open
sdunham opened this issue Sep 3, 2021 · 0 comments
Open

Better handling for malformed recurrence data #16

sdunham opened this issue Sep 3, 2021 · 0 comments
Assignees

Comments

@sdunham
Copy link
Contributor

sdunham commented Sep 3, 2021

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?)

@sdunham sdunham self-assigned this Sep 3, 2021
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

No branches or pull requests

1 participant