From 4e2d91d186b8f24381c1da52d778ddc355fd6436 Mon Sep 17 00:00:00 2001 From: Jake Spurlock Date: Mon, 14 Oct 2019 16:23:13 +0000 Subject: [PATCH] REST API: Ensure that we don't generate warnings from sending extra headers after headers have been sent. Fixes issues stemming from [46478]. git-svn-id: https://develop.svn.wordpress.org/trunk@46483 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/rest-api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php index b998cf7cda..653abc0c8d 100644 --- a/src/wp-includes/rest-api.php +++ b/src/wp-includes/rest-api.php @@ -589,7 +589,7 @@ function rest_send_cors_headers( $value ) { header( 'Access-Control-Allow-Methods: OPTIONS, GET, POST, PUT, PATCH, DELETE' ); header( 'Access-Control-Allow-Credentials: true' ); header( 'Vary: Origin' ); - } else if ( 'GET' === $_SERVER['REQUEST_METHOD'] && ! is_user_logged_in() ) { + } elseif ( ! headers_sent() && 'GET' === $_SERVER['REQUEST_METHOD'] && ! is_user_logged_in() ) { header( 'Vary: Origin' ); }