Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions features/cron.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
<?php
define( 'ALTERNATE_WP_CRON', true );
"""
And a wp-cli.yml file:
"""
require:
- alternate-wp-cron.php
"""

When I run `wp eval 'var_export( ALTERNATE_WP_CRON );'`
Then STDOUT should be:
"""
true
"""

When I run `wp option get home`
Then STDOUT should be:
"""
http://example.com
"""
7 changes: 7 additions & 0 deletions php/WP_CLI/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down