[DOC REQUEST] A note about Cron and fastcgi_finish_request()
What do you think is missing from the documentation?
Might be worth to add a small note here or as a Tutorial, talking about the fastcgi_finish_request() that was added on wp-cron.php on WordPress 5.1.
It basically returns a response to the browser at the first lines of wp-cron.php, so the browser doesn't have to wait for PHP to finish the script execution. The problem with that is that you can't assert on the output of Cron requests.
My use case, for instance
public function test_is_cron_request( FunctionalTester $I ) {
$code = <<<PHP
/** Plugin Name: Test */
add_action( 'wp', function () {
echo sprintf('<div id="test-response">%d</div>', (int) App\Service_Providers\Cron_Providers\Cron_Service_Provider::should_register());
exit;
} );
PHP;
$I->haveMuPlugin( "test.php", $code );
$I->amOnCronPage( [ 'doing_cron' => true ] );
$I->see( "1", "#test-response" );
}
Given this context, I'm still not sure how I'm going to test that. Probably going through the database, if at all.
Do you have any examples of what you'd like to see added to the documentation? I think the commit that added this explains this feature well enough.