From acbf549f900835664fd306a88ffdb136ffb7edca Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Thu, 7 Jul 2016 06:00:32 -0700 Subject: [PATCH 1/2] Failing test case for #3104 --- features/cron.feature | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/features/cron.feature b/features/cron.feature index 76b1ee0e81..253938dd0f 100644 --- a/features/cron.feature +++ b/features/cron.feature @@ -280,3 +280,27 @@ Feature: Manage WP-Cron events and schedules """ Executed a total of 0 cron event(s) """ + + Scenario: Don't trigger cron when ALTERNATE_WP_CRON is defined + Given a alternate-wp-cron.php file: + """ + Date: Thu, 7 Jul 2016 06:07:02 -0700 Subject: [PATCH 2/2] Don't trigger cron when ALTERNATE_WP_CRON is defined `ALTERNATE_WP_CRON` tries to redirect, which we can't handle. --- php/WP_CLI/Runner.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/php/WP_CLI/Runner.php b/php/WP_CLI/Runner.php index 81494257f0..fa6630ff24 100644 --- a/php/WP_CLI/Runner.php +++ b/php/WP_CLI/Runner.php @@ -1014,6 +1014,13 @@ private function setup_bootstrap_hooks() { return $headers; }); + // ALTERNATE_WP_CRON might trigger a redirect, which we can't handle + if ( defined( 'ALTERNATE_WP_CRON' ) && ALTERNATE_WP_CRON ) { + $this->add_wp_hook( 'muplugins_loaded', function() { + remove_action( 'init', 'wp_cron' ); + }); + } + // Get rid of warnings when converting single site to multisite if ( defined( 'WP_INSTALLING' ) && $this->is_multisite() ) { $values = array(