Guarded action scheduler - #1376
Conversation
There was a problem hiding this comment.
Note
Copilot was unable to run its full agentic suite in this review.
Pull request overview
This PR adds safeguards and fallbacks around scheduling so the plugin can avoid fatal errors on older WordPress versions (or environments missing required Action Scheduler capabilities) while keeping the DB-refresh job running.
Changes:
- Gate loading/usage of the bundled Action Scheduler behind a compatibility check (
wpdb::db_server_info()availability). - Add an
init-time rescheduler to ensure WP-Cron gets re-armed when Action Scheduler isn’t usable. - Normalize Gutenberg block
visualizer-settingsmeta to an array before accessing nested keys; bump local.wp-envPHP version.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
index.php |
Adds visualizer_can_use_action_scheduler() and uses it to guard Action Scheduler loading. |
classes/Visualizer/Module/Setup.php |
Uses the new guard when scheduling via Action Scheduler; adds maybe_reschedule_refresh_db() on init to re-arm WP-Cron. |
classes/Visualizer/Gutenberg/Block.php |
Ensures settings meta is an array before reading nested settings. |
.wp-env.json |
Updates local dev PHP version to 8.1. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| { | ||
| "core": null, | ||
| "phpVersion": "7.4", | ||
| "phpVersion": "8.1", |
There was a problem hiding this comment.
The PHP 7.4 wp-env image is based on Debian Bullseye, whose security repository release file has expired. As a result, apt-get update fails and the image build cannot complete.
Therefore, I bumped the PHP version to 8.1 so the test environment can build and the test case can run successfully. This change is only for the test environment and does not mean that the plugin's minimum supported PHP version has been increased to 8.1.
There was a problem hiding this comment.
Verified that readme.txt, composer.json, and CI still declare PHP 7.4 support. The new void return type is valid on PHP 7.4 and already exists in this class. The wp-env change does not alter runtime support.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
🤖 Review agent — review posted ✅
Run |
pirate-bot
left a comment
There was a problem hiding this comment.
Needs human check: Verify the WordPress 5.3 fallback and queue path before merge.
The changed guards are consistent, and the focused current-WordPress checks passed.
Validation details
- The WordPress sandbox confirmed the migration replaces WP-Cron with Action Scheduler when its APIs exist.
- PHP 8.3 parsed all changed PHP files without errors.
- The settings writers store arrays, so the new normalization preserves supported values.
- The changed hunks introduced no security boundary issue.
Untested areas
- WordPress 5.3 queue execution was not run.
- The isolated fallback harness stopped on an unrelated unstubbed
register_post_type()callback.
🤖 Automated review · run code-review-agent_6aa15617165b44.77709822.
Summary
Guarded the action scheduler function to prevent the error.
Check before Pull Request is ready:
Closes #1361
Why no test cases
wpdb::db_server_info()is available only in WP 5.5+, while the issue also affects versions before WP 5.5. Therefore, I didn't add test cases for this.