feat(integrations): add ActionScheduler group handling#4559
feat(integrations): add ActionScheduler group handling#4559miguelpeixe wants to merge 21 commits intotrunkfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces Action Scheduler “group” namespacing for Newspack so scheduled actions can be attributed and queried per integration/subsystem, and adds helper APIs to query those actions.
Changes:
- Assign integration-specific Action Scheduler groups (e.g.
newspack-integration-{$integration_id}) for retries and async contact pulls. - Move other subsystems to dedicated groups (e.g.
newspack-webhooks,newspack-sync) and update affected scheduling calls/tests. - Add a new
Newspack\Action_Schedulerutility class plus new query helpers on Integrations/Integration.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit-tests/reader-activation-sync.php | Updates assertions to look for per-integration AS groups. |
| tests/unit-tests/integrations/class-test-integrations.php | Adds unit tests for group-resolution helpers and filter behavior. |
| includes/reader-activation/sync/class-contact-sync.php | Schedules integration retry actions under integration-specific groups. |
| includes/reader-activation/sync/class-contact-sync-admin.php | Schedules bulk admin sync actions under a dedicated newspack-sync group. |
| includes/reader-activation/integrations/class-integration.php | Adds get_action_group() and get_scheduled_actions() convenience methods. |
| includes/reader-activation/integrations/class-contact-pull.php | Schedules async pulls under integration-specific groups and dedupes by that group. |
| includes/reader-activation/class-integrations.php | Adds group helpers, handler->group filter, and integration-scoped scheduled action querying. |
| includes/data-events/class-webhooks.php | Moves webhook AS actions to newspack-webhooks group. |
| includes/data-events/class-data-events.php | Adds filterable handler group resolution and uses it for handler retries/default dispatch group. |
| includes/class-newspack.php | Ensures the new Action Scheduler helper file is included. |
| includes/class-action-scheduler.php | Introduces a DB-backed helper for listing groups by prefix and querying actions by group(s). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
All Submissions:
Changes proposed in this Pull Request:
Separates Newspack's AS actions into dedicated groups so each integration and subsystem can be identified and queried. Because AS has a separate
wp_actionscheduler_groupstable, we can safely find existing groups using a wildcard search before querying the actions table with indexed groups.newspack-integration-{$integration_id}, covering handler retries, sync retries, and async contact pulls*newspack-webhooks, bulk admin syncs usenewspack-sync*The first run of a data event handler cannot be in an integration group because a single data event dispatch runs all handlers in a single AS action. Only retries spin an action for a single handler. The same goes for syncs, which don't run as an AS action until it requires a retry.
How to test the changes in this Pull Request:
newspack-integration-espgroup rather than the genericnewspackgroup.get_scheduled_actions()APIs withwp shell:Other information: