Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/wp-includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3886,6 +3886,19 @@ function _default_wp_die_handler( $message, $title = '', $args = array() ) {
$message .= "\n<p><a href='javascript:history.back()'>$back_text</a></p>";
}

// Ensure HTTP 500 status code for critical errors, even if headers were already sent.
$is_critical_error = false;
if ( $message instanceof WP_Error ) {
$is_critical_error = $message->get_error_code();
} elseif ( 'internal_server_error' === $parsed_args['code'] || 500 === $parsed_args['response'] ) {
$is_critical_error = true;
}

if ( $is_critical_error ) {
$parsed_args['response'] = 500;
http_response_code( 500 );
}

if ( ! did_action( 'admin_head' ) ) :
if ( ! headers_sent() ) {
header( "Content-Type: text/html; charset={$parsed_args['charset']}" );
Expand Down
Loading