Open WPprodigy opened 5 years ago
For posterity, the relevant part of my reply from Slack:
Action Scheduler's WP CLI command already has that: https://github.com/Prospress/action-scheduler/blob/master/classes/ActionScheduler_WPCLI_QueueRunner.php#L118
But I guess the migration commands are using something else...
Yeah OK, the migration has it's own command which isn't stopping the insanity: https://github.com/Prospress/action-scheduler-custom-tables/blob/master/src/WP_CLI/Migration_Command.php#L69:L72
Unfortunately, ActionScheduler_WPCLI_QueueRunner::stop_the_insanity()
is protected. So we'll likely need to implement a custom method for this.
The only other options would be to have Migration_Command
extend ActionScheduler_WPCLI_QueueRunner
, which isn't great, or make that method public
, then update the dependency to require AS 2.2.0 or similar, also not great. Although I guess ideally, we refactor ActionScheduler_WPCLI_QueueRunner::stop_the_insanity()
to make it publicly accessible, then use that when available in Migration_Command
.
I think the way to handle this is after merging the custom tables into action scheduler make a base WP_CLI class that has the stop_the_insanity()
so it can be implemented in both commands (plus any commands we might want to add later).
In AS, you'll see the the common
stop_the_insanity()
function in use: https://github.com/Prospress/action-scheduler/blob/master/classes/ActionScheduler_WPCLI_QueueRunner.php#L118I had to do something similar for the migration command to prevent the process from being killed by the server.
I added a call to the function here at the end of the loop: https://github.com/Prospress/action-scheduler-custom-tables/blob/master/src/WP_CLI/Migration_Command.php#L71
Things to consider: