From e06121f2edd51056ef7ca2d908df7cac0fcb2193 Mon Sep 17 00:00:00 2001 From: Alex Shiels Date: Wed, 9 Jan 2019 01:05:16 +0000 Subject: [PATCH] Cron API: Make wp-cron.php non-blocking where possible. This should make cron spawning faster by ensuring requests to wp-cron.php return immediately regardless of transport method. It is enabled only on recent PHP versions with fastcgi, due to historical bugs and availability of `fastcgi_finish_request()`. This needs testing on a range of platforms, to help determine if it's safe to use in other contexts also. Props vnsavage, johnbillion, jnylen0. See #18738, #41358 git-svn-id: https://develop.svn.wordpress.org/trunk@44488 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-cron.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wp-cron.php b/src/wp-cron.php index d704ceaf84..d487770f71 100644 --- a/src/wp-cron.php +++ b/src/wp-cron.php @@ -18,6 +18,11 @@ ignore_user_abort( true ); +/* Don't make the request block till we finish, if possible. */ +if ( function_exists( 'fastcgi_finish_request' ) && version_compare( phpversion(), '7.0.16', '>=' ) ) { + fastcgi_finish_request(); +} + if ( ! empty( $_POST ) || defined( 'DOING_AJAX' ) || defined( 'DOING_CRON' ) ) { die(); }