-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add bulk cancel by hook/group to table store #351
Conversation
@thenbrent The test failure was a travis download/install error. I don't have the option to restart the test. |
@rrennick this is looking good. I think it needs a few additions though:
|
In WC Admin, we opted to cancel the actions and allow them to be removed by the auto purge in Action Scheduler instead of deleting the actions as changing the status could be done with a single query. For the purposes of plugin deactivation I think it would be better to provide a method of deleting any related pending actions than cancelling and adding log entries. |
I was thinking about this issue when fixing recurring schedules. The persistence of recurring actions after deactivating the plugin which created and required them is a strong argument for removing recurring schedules completely. If all actions where "single", and any successive action needed to be rescheduled by the plugin using it, based on the when the prior one ran, they would automatically be cease to recur once that plugin was deactivated and wouldn't need to be cancelled. This is mostly moot now because I went the route of fixing schedules, but I'm noting it as an alternative approach. I still think having a log is important to help trace the reason for the cancellation (and time/date). |
@thenbrent Can you restart the one test that failed? It ran right about midnight UTC, so tomorrow could have been in 30 seconds and subtracting the minute put If that test passes, this is ready for re-review. |
By implementing fallback logging methods, and making sure the 'action_scheduler_bulk_cancel_actions' hook is called when using the fallback ActionScheduler_Store::cancel_actions_by_* methods.
This LGTM. I added SHA: 76e149d to provide logging for bulk cancellation done via the |
This PR adds two bulk cancel functions to the table data store with a unit test for each function
cancel_actions_by_group( $group_slug )
cancels pending actions by groupcancel_actions_by_hook( $hook_name )
cancels pending actions by hookThis is a prerequisite for woocommerce/woocommerce-admin#2766 to allow bulk cancelation of pending actions.
In future, other plugins using AS will also be able to take advantage of these function to cancel their pending actions on de-activation.