Skip to content

Guarded action scheduler - #1376

Open
girishpanchal30 wants to merge 3 commits into
developmentfrom
bugfix/1361
Open

Guarded action scheduler#1376
girishpanchal30 wants to merge 3 commits into
developmentfrom
bugfix/1361

Conversation

@girishpanchal30

Copy link
Copy Markdown
Contributor

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.

@girishpanchal30 girishpanchal30 added the pr-checklist-skip Allow this Pull Request to skip checklist. label Sep 9, 2026
@pirate-bot

pirate-bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Plugin build for 6238fa6 is ready 🛎️!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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-settings meta to an array before accessing nested keys; bump local .wp-env PHP 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.

Comment thread .wp-env.json
{
"core": null,
"phpVersion": "7.4",
"phpVersion": "8.1",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread classes/Visualizer/Module/Setup.php Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@pirate-bot

pirate-bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🤖 Review agent — review posted ✅

Run code-review-agent_6aa15617165b44.77709822 · trail

@pirate-bot pirate-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-checklist-skip Allow this Pull Request to skip checklist.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants