Skip to content

fix(events): handle invalid recurring schedule intervals - #537

Merged
rinatkhaziev merged 2 commits into
mainfrom
fix/invalid-recurring-event-interval
Nov 13, 2026
Merged

rinatkhaziev merged 2 commits into
mainfrom
fix/invalid-recurring-event-interval

Conversation

@rinatkhaziev

@rinatkhaziev rinatkhaziev commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Recurring events can crash with DivisionByZeroError: Modulo by zero when a cron_schedules filter returns a zero interval. Fall back to the saved interval when the refreshed value is missing or nonpositive, and return the existing invalid-schedule WP_Error if neither interval is usable.

Two focused regression tests cover rescheduling an overdue event with a zero refreshed interval and rejecting an unusable saved interval before changing the timestamp.

Validation: PHP 8.3 single-site suite passed (48 tests, 300 assertions, two multisite-only skips); PHPCS and git diff --check passed. The Docker harness emitted its empty database-name warning during setup; WordPress installation and the test suite completed successfully.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@rinatkhaziev
rinatkhaziev requested review from sjinks and a balanced review from Copilot November 7, 2026 02:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the rescheduling interval-validation change.

No open issues 🎉

What changed in this PR

Prevents recurring-event rescheduling from dividing by zero when a refreshed schedule interval is invalid.

Changes:

  • Falls back to the saved interval when the refreshed interval is missing or nonpositive.
  • Returns the existing invalid-schedule WP_Error before calculating a timestamp if neither interval is usable.
  • Adds regression tests for zero-interval fallback and rejection without timestamp changes.
File Description
includes/​class-event.php Validates intervals and falls back to the saved value before rescheduling.
__tests__/​unit-tests/​test-event.php Tests fallback behavior and timestamp preservation on invalid schedules.

Review effort: Balanced

@rinatkhaziev
rinatkhaziev merged commit 4ccb953 into main Nov 13, 2026
18 checks passed
@rinatkhaziev
rinatkhaziev deleted the fix/invalid-recurring-event-interval branch November 13, 2026 19:04
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.

3 participants