Commit 15582049 authored by Erick Hitter's avatar Erick Hitter
Browse files

CLI: when running `cron-control` commands, create the table if necessary

parent 9751ac77
......@@ -6,6 +6,27 @@ if ( ! defined( '\WP_CLI' ) || ! \WP_CLI ) {
return;
}
/**
* Prepare environment
*/
if ( ! \Automattic\WP\Cron_Control\Events_Store::is_installed() ) {
// Only interfere with `cron-control` commands
$cmd = \WP_CLI::get_runner()->arguments;
if ( ! is_array( $cmd ) || ! isset( $cmd['0'] ) ) {
return;
}
$cmd = $cmd[0];
if ( false === strpos( $cmd, 'cron-control' ) ) {
return;
}
// Create table and die, to ensure command runs with proper state
\Automattic\WP\Cron_Control\Events_Store::instance()->cli_create_tables();
\WP_CLI::error( __( 'Cron Control installation completed. Please try again.', 'automattic-cron-control' ) );
}
/**
* Consistent time format across commands
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment