2

My WordPress site was failing to run scheduled tasks. I went through wp-cron.php and found that commenting-out the following if-statement resolved the problem:

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

My guess is that using Unit as an application server, rather than FastCGI, causes problems for this code.

Can someone tell me if this is correct? Why does running this function stop execution of the rest of the script? Is it safe to comment-out this statement, or should I make some different change to workaround this?

thanks

1 Answers1

1

From what I've seen there is no workaround to run wp-cron.php through a GET request, except commenting those lines.

However, you can run wp-cron.php by running php /path/to/wordpress/wp-cron.php from your command line, or setting a system cron (for example, every 10 minutes):

10 * * * * php /path/to/wordpress/wp-cron.php > /dev/null 2>&1
JesusIniesta
  • 10,412
  • 1
  • 35
  • 28