Commit 251c308b authored by Erick Hitter's avatar Erick Hitter
Browse files

Ensure that expired timestamps are cleared

parent 633d9b53
......@@ -37,11 +37,21 @@ class Events extends Singleton {
* Set initial options that control event behaviour
*/
public function prime_options() {
// Prime option to disable automatic execution
if ( is_admin() || ( defined( 'WP_CLI' ) && \WP_CLI ) || false !== get_endpoint_type() ) {
add_option( self::DISABLE_RUN_OPTION, 0, null, false );
}
$this->run_disabled = get_option( self::DISABLE_RUN_OPTION, 0 );
// Check if execution is disabled, or if timestamp has passed
$disabled = get_option( self::DISABLE_RUN_OPTION, 0 );
if ( $disabled <= 1 ) {
$this->run_disabled = $disabled;
} elseif ( $disabled > time() ) {
$this->run_disabled = $disabled;
} else {
update_option( self::DISABLE_RUN_OPTION, 0 );
$this->run_disabled = 0;
}
}
/**
......
......@@ -86,7 +86,7 @@ class Orchestrate extends \WP_CLI_Command {
array(
'multisite' => is_multisite() ? 1 : 0,
'siteurl' => site_url(),
'disabled' => get_option( \Automattic\WP\Cron_Control\Events::DISABLE_RUN_OPTION, 0 ),
'disabled' => \Automattic\WP\Cron_Control\Events::instance()->run_disabled(),
),
);
......
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