Skip to content

Testing Action Scheduler

Barry Hughes edited this page Jun 19, 2023 · 1 revision

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:

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.


Check the admin screen is available

woocommerce-status-schedule-actions

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).

Functional test: check actions are generated and processed

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

Now edit a product, and create a new attribute, then save:

add-product-attrs

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

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

Notes

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.
Clone this wiki locally