-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Testing Action Scheduler
Action Scheduler is used as the default backend for the WooCommerce task queue. It's used for a range of tasks, some that are essential and others less so. Examples:
- Population of look-up tables used by Analytics.
- Running database migrations after a plugin update.
It's generally not something that we expect our users to interact with directly, but is an important component nonetheless. A reasonable way to test it is basically working (as part of our pre-release testing) is outlined below.
![woocommerce-status-schedule-actions](https://private-user-images.githubusercontent.com/3594411/246931161-d8993706-822d-4268-b336-0ac04ef410f7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDc0NTMsIm5iZiI6MTcyNjEwNzE1MywicGF0aCI6Ii8zNTk0NDExLzI0NjkzMTE2MS1kODk5MzcwNi04MjJkLTQyNjgtYjMzNi0wYWMwNGVmNDEwZjcucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDkxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA5MTJUMDIxMjMzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MzBlNGYzY2UyZjQ5ZTkwOWFmMjk5OTliNmYyYzI0MGI3N2M3ZDE3MTIzZGZhNWY2ZjA2MDM2OWEwZDQxMTE4MiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.Lz0FfZBZQYxElj-Lwo2p0nQivYdfbyWa2cbKBRqnH-I)
Action Scheduler provides an admin screen that can be used to check on the status of actions, and to manually run them. What is essentially the same admin screen is generally found in two separate locations:
- Tools ▸ Scheduled Actions (default screen)
- WooCommerce ▸ Status ▸ Scheduled Actions (duplicate screen: sometimes needed because the above admin screen may be unhooked or hidden by other plugins)
Within this page, you should be able to:
- Search for actions (the hook and argument fields are searched).
- Manually run any pending actions.
- Delete actions (bulk action dropdown).
Navigate to WooCommerce ▸ Settings ▸ Products ▸ Advanced and enable the Product Attribute Lookup Table, making sure the Direct Updates option is not enabled:
![wc-settings-products-advanced](https://private-user-images.githubusercontent.com/3594411/246931776-105064f0-0c3d-4eac-b4ed-7548c8288150.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDc0NTMsIm5iZiI6MTcyNjEwNzE1MywicGF0aCI6Ii8zNTk0NDExLzI0NjkzMTc3Ni0xMDUwNjRmMC0wYzNkLTRlYWMtYjRlZC03NTQ4YzgyODgxNTAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDkxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA5MTJUMDIxMjMzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZjVjYjRjNGJiMTU4ODY2ZGNjMjFiZTg3NTRkODIyNmU5MzQwY2JkNWQ5MDliMGYyOTM0ZTdjYjEwZDVhOTcyYyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.IF-vmA45bP2_O98yIinHDd_yY_EywHBEepUmrJVgr8I)
Now edit a product, and create a new attribute, then save:
![add-product-attrs](https://private-user-images.githubusercontent.com/3594411/246932044-a1a6aed3-cc42-4bf6-87b0-689bc9408463.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDc0NTMsIm5iZiI6MTcyNjEwNzE1MywicGF0aCI6Ii8zNTk0NDExLzI0NjkzMjA0NC1hMWE2YWVkMy1jYzQyLTRiZjYtODdiMC02ODliYzk0MDg0NjMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDkxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA5MTJUMDIxMjMzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9M2E2MWQ3MzAwNmE3NTE1OGE3MGZmZDU2MDU2Y2JmM2M4NjY1YWU0OGUwNWUxZmRlZGM2Zjk2Y2FiNTUxOWY3MCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.j5qTEW9dLPeQ1T6pcaeCbn3qs6iKl9utAUPXfz9uaMw)
This should result in a scheduled action being generated. Visit either of the Scheduled Actions admin screens, and you should be able to locate an action named woocommerce_run_product_attribute_lookup_update_callback
(if you have a lot of actions you can use the search feature to filter them down):
![sched-actions-product-attr-callback](https://private-user-images.githubusercontent.com/3594411/246932215-e10d5fb8-ccf4-4353-a4e8-4d56c16b618c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDc0NTMsIm5iZiI6MTcyNjEwNzE1MywicGF0aCI6Ii8zNTk0NDExLzI0NjkzMjIxNS1lMTBkNWZiOC1jY2Y0LTQzNTMtYTRlOC00ZDU2YzE2YjYxOGMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDkxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA5MTJUMDIxMjMzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZjNkOGY5MzI1ZmQxZDY3MWVmNzk5YzQ4YzZjOTY1NGQ2ZmM0NGUxZTY0YTY0MDViNzU2OGY4ZTYwMTBhMzdlNCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.75NrrB4xnFsxznLMLFHkbxGHoE0DE3E2jr16KMAx7NM)
If Action Scheduler is running as expected, you should find that these become Complete after some time elapses (around two minutes). Or, you can force Action Scheduler to run via WP CLI:
wp action-scheduler run
Without WP CLI, Action Scheduler depends either on WP Cron, or on its own ability to spawn queue-processing requests over HTTP (very similar to how WP Cron works by default). This is not bulletproof, and various factors can stop it from working. In general:
- If you can process the queue via WP CLI, as detailed above, then Action Scheduler itself is probably working just fine.
- If it isn't working without WP CLI, you may wish to check in other WP Cron-based tasks are being processed. Often, if these are blocked, Action Scheduler will also be blocked.
WooCommerce is an open source commerce platform built for WordPress and lovingly crafted by Automattic and the WooCommerce community 💜. Come and work with us!
Contribution
- Set up development environment
- Our Git Flow
- SCSS and JS minification
- Naming conventions
- CSS SASS coding guidelines and naming conventions
- Critical Flows
- API Critical Flows
- String localisation guidelines
- Translating WooCommerce
- Deprecation in core
- Adding Actions and Filters
- Common Issues
- Writing high-quality testing instructions
Release Notes
- Release Testing Instructions
- 3.6.x notes/FAQ
- 2.6.x to 3.0.0 Developer Migration Notes
- Select2 fields not working in 3.0.x
- Thumbnail Image Regeneration in 3.3+
- Customizing image sizes in 3.3+
REST API and CLI
CRUD & Data Descriptions
- Database Description
- CRUD Objects in 3.0
- Order and Order Line Item Data
- Coupon Data
- Customer Data
- Product Data
- Data Stores
Internal APIs
Theming
- Enabling product gallery features (zoom, swipe, lightbox)
- Template File Guidelines for Devs and Theme Authors
Examples / Guides