Log if headers cannot be sent during a download error event.

This commit is contained in:
barryhughes 2022-04-27 07:46:21 -07:00
parent fbb96048a2
commit 72d196f398
1 changed files with 3 additions and 1 deletions

View File

@ -665,7 +665,9 @@ class WC_Download_Handler {
* Since we will now render a message instead of serving a download, we should unwind some of the previously set
* headers.
*/
if ( ! headers_sent() ) {
if ( headers_sent() ) {
wc_get_logger()->log( 'warning', __( 'Headers already sent when generating download error message.', 'woocommerce' ) );
} else {
header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
header_remove( 'Content-Description;' );
header_remove( 'Content-Disposition' );