Skip to content

Instantly share code, notes, and snippets.

@barryhughes
Last active December 21, 2022 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barryhughes/0cd53aee7abaa61d2ca71462aa9f0753 to your computer and use it in GitHub Desktop.
Save barryhughes/0cd53aee7abaa61d2ca71462aa9f0753 to your computer and use it in GitHub Desktop.
Cleanup `woocommerce_run_update_callback` actions.
-- Cleans up any non-pending WooCommerce Update Callback scheduled actions
-- and the corresponding log table entries.
--
-- Note that in many cases you may need to adjust the table prefix from
-- 'wp_' to whatever is in effect within your site.
DELETE actions,
action_logs
FROM wp_actionscheduler_actions AS actions
JOIN wp_actionscheduler_logs AS action_logs
ON actions.action_id = action_logs.action_id
WHERE actions.hook = 'woocommerce_run_update_callback'
AND actions.status <> 'pending'
-- The following AND condition is optional, but may be useful on sites
-- with very large numbers of `woocommerce_run_update_callback` actions.
-- In effect, it reduces the number of rows that will be cleaned up
-- (noting here that a LIMIT clause is not possible in this sort of query).
--
-- To utilize it, simply uncomment the following line beginning 'AND'. Then,
-- on each subsequent run of the query, increase the interval as appropriate.
-- AND actions.scheduled_date_gmt > DATE_SUB( NOW(), INTERVAL 1 DAY )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment