Mainwilliam/pro 670 make the cleanup routine for orphaned issues run twice a day #1580
Conversation
Release v1.38.0
Release v1.39.0
Also adds some catching to reschedule it if it's on a daily timer
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the orphaned issues cleanup routine by making its scheduling more robust and maintainable. It introduces a dedicated class constant for defining the recurrence interval and ensures that the cleanup event is always scheduled with the latest configuration, specifically setting it to run twice daily. This change improves the reliability and flexibility of the background task management. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe orphaned issues cleanup class adds a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 PHPStan (2.1.40)Composer install failed: this project depends on private packages that require authentication (e.g. GitLab/GitHub, Laravel Nova, etc.). Instead, run PHPStan in a CI/CD pipeline where you can use custom packages — our pipeline remediation tool can use the PHPStan output from your CI/CD pipeline. Comment |
There was a problem hiding this comment.
Code Review
This pull request refactors the scheduling logic for the orphaned issues cleanup event to be more flexible. The introduction of a RECURRENCE constant and logic to reschedule the event if the recurrence changes are good improvements. I've suggested a small refactoring to the schedule_event method to make the logic more concise and robust by using wp_clear_scheduled_hook and simplifying the conditional checks.
There was a problem hiding this comment.
Pull request overview
This PR updates the orphaned-issues cleanup cron scheduling to run twice per day and makes the recurrence easier to maintain by centralizing it in a class constant, while also ensuring the cron event is rescheduled if the configured recurrence changes.
Changes:
- Added a
RECURRENCEclass constant (set totwicedaily) for the cleanup cron schedule. - Updated
schedule_event()to detect an existing scheduled event and reschedule it if the recurrence differs.
| if ( self::RECURRENCE !== $event->schedule ) { | ||
| wp_unschedule_event( $event->timestamp, self::EVENT ); | ||
| wp_schedule_event( time(), self::RECURRENCE, self::EVENT ); |
There was a problem hiding this comment.
There should not be situations where there are several hooked in. We only ever scheduled one. But if there are several that isn't a huge problem because it just means it will clear orphans faster.
This pull request updates the scheduling logic for the orphaned issues cleanup event to allow for more flexible and maintainable recurrence intervals. The main focus is on introducing a class constant for the recurrence setting and ensuring the event is rescheduled if the recurrence changes.
Scheduling improvements:
RECURRENCEclass constant inclass-orphaned-issues-cleanup.phpto define the cleanup event's recurrence interval, making it easier to update and maintain.schedule_eventmethod to check if the event is scheduled with the correct recurrence, and if not, unschedule and reschedule it with the new interval. This ensures the event always uses the latest recurrence configuration.Checklist
Summary by CodeRabbit