feat: use Action Scheduler for background jobs when available#172
Open
HardeepAsrani wants to merge 1 commit into
Open
feat: use Action Scheduler for background jobs when available#172HardeepAsrani wants to merge 1 commit into
HardeepAsrani wants to merge 1 commit into
Conversation
Route all background jobs (post processing, deletion, updates and Qdrant migration) through Action Scheduler when another plugin on the site provides it, falling back to WP-Cron otherwise. Adds a thin Scheduler helper that detects Action Scheduler at call time, so there is no new dependency and the existing WP-Cron behaviour is preserved when it is unavailable.
Soare-Robert-Daniel
approved these changes
Jul 1, 2026
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
Routes Hyve Lite's background jobs through Action Scheduler when it is available on the site (e.g. provided by WooCommerce or another plugin), and falls back to WP-Cron when it is not. No new dependency is added and Action Scheduler is not bundled — heavier sites benefit automatically, everyone else keeps the current behaviour.
Part of Codeinwp/hyve#37.
Pro PR: https://github.com/Codeinwp/hyve/pull/206
Changes
ThemeIsle\HyveLite\Schedulerhelper (inc/Scheduler.php) with three static methods that detect Action Scheduler at call time viafunction_exists():enqueue_async()→as_enqueue_async_action()/wp_schedule_single_event( time(), … )schedule_single()→as_schedule_single_action()/wp_schedule_single_event( time() + N, … )ensure_recurring()→as_schedule_recurring_action()/wp_schedule_event()hyvegroup (visible under Tools → Scheduled Actions).ensure_recurring()self-heals: when AS is present it removes any legacy WP-Cron copy and uses AS; if AS later disappears it falls back to WP-Cron.DB_Table.php(process/update/delete posts + the hourlyhyve_update_posts),Main.php,Qdrant_API.php(Qdrant migration) andAPI.php. Action handlers (add_action) are unchanged — Action Scheduler fires the samedo_action().QA / Testing
With Action Scheduler present (install + activate WooCommerce, or any plugin that ships Action Scheduler):
hyvegroup.hyve_process_post(and, after edits,hyve_update_posts) actions appear, run, and end up Complete.hyve_lite_migrate_dataaction appears and migrates existing entries.Without Action Scheduler (deactivate WooCommerce / any AS provider):
hyve_process_post/hyve_update_postsevents scheduled there.Switching (regression for the self-healing path):
hyve_update_postsshould now live there (and the old WP-Cron entry should be gone).