fix(events): persist refreshed recurrence intervals - #524
Open
sjinks wants to merge 1 commit into
Open
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This pull request fixes recurring event rescheduling so that when the WordPress cron schedule interval has been refreshed/changed, the updated interval is persisted on the saved event and used to compute the next run time.
Changes:
- Persist the refreshed schedule interval during
Event::reschedule()when the interval has changed. - Add a unit test covering interval refresh persistence and next-run scheduling based on the refreshed interval.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| includes/class-event.php | Updates reschedule logic to save the refreshed recurrence interval. |
| tests/unit-tests/test-event.php | Adds a unit test to verify refreshed intervals are persisted and used for scheduling. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+90
to
+99
| add_filter( 'cron_schedules', $filter ); | ||
|
|
||
| $result = $event->reschedule(); | ||
|
|
||
| remove_filter( 'cron_schedules', $filter ); | ||
| $reloaded_event = Event::get( $event->get_id() ); | ||
| $this->assertTrue( $result, 'event was successfully rescheduled' ); | ||
| $this->assertInstanceOf( Event::class, $reloaded_event ); | ||
| $this->assertEquals( 2 * HOUR_IN_SECONDS, $reloaded_event->get_interval(), 'the refreshed interval was saved' ); | ||
| $this->assertEqualsWithDelta( time() + ( 2 * HOUR_IN_SECONDS ), $reloaded_event->get_timestamp(), 1 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Testing
php -l includes/class-event.phpphp -l __tests__/unit-tests/test-event.php./vendor/bin/phpcs --standard=phpcs.xml includes/class-event.php __tests__/unit-tests/test-event.phpgit diff --check./vendor/bin/phpunit __tests__/unit-tests/test-event.php(blocked locally: WordPress test bootstrap at/tmp/wordpress-tests-liband its MariaDB database are unavailable)Fixes PLTFRM-2761.