Skip to content
Open
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
16 changes: 10 additions & 6 deletions src/wp-cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,22 @@
* @package WordPress
*/

ignore_user_abort( true );

if ( ! headers_sent() ) {
header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
}

if ( defined( 'WP_CRON_IGNORE_ABORT' ) && true === WP_CRON_IGNORE_ABORT ) {
ignore_user_abort( true );
}

// Don't run cron until the request finishes, if possible.
if ( function_exists( 'fastcgi_finish_request' ) ) {
fastcgi_finish_request();
} elseif ( function_exists( 'litespeed_finish_request' ) ) {
litespeed_finish_request();
if ( defined( 'WP_CRON_FLUSH' ) && true === WP_CRON_FLUSH ) {
if ( function_exists( 'fastcgi_finish_request' ) ) {
fastcgi_finish_request();
} elseif ( function_exists( 'litespeed_finish_request' ) ) {
litespeed_finish_request();
}
}

if ( ! empty( $_POST ) || defined( 'DOING_AJAX' ) || defined( 'DOING_CRON' ) ) {
Expand Down
24 changes: 24 additions & 0 deletions src/wp-includes/default-constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,30 @@ function wp_functionality_constants() {
if ( ! defined( 'WP_CRON_LOCK_TIMEOUT' ) ) {
define( 'WP_CRON_LOCK_TIMEOUT', MINUTE_IN_SECONDS );
}

/**
* Wether or not to ignore user abort when running wp-cron
*
* @see https://www.php.net/manual/en/function.ignore-user-abort.php
*/
if ( ! defined( 'WP_CRON_IGNORE_ABORT' ) ) {
define( 'WP_CRON_IGNORE_ABORT', true );
}

/**
* Flush wp-cron response data
*
* Wether or not to flush wp-cron response data and close the HTTP request
* before continuing in the background. This invokes a child process in
* PHP-FPM and LSPHP and closes the HTTP connection to the client.
*
* @link https://www.php.net/manual/en/function.ignore-user-abort.php
* @link https://www.php.net/manual/en/function.fastcgi-finish-request.php
* @link https://www.php.net/manual/en/function.litespeed-finish-request.php
*/
if ( ! defined( 'WP_CRON_FLUSH' ) ) {
define( 'WP_CRON_FLUSH', true );
}
}

/**
Expand Down
Loading