mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 09:07:59 +01:00
Bootstrap/Load: Always run the fatal error handler at shutdown, but don't display the PHP error template once headers are sent.
If a fatal error occurs midway through a page load, or in a REST API request, it still needs to be handled internally for the recovery mode, but the custom message may conflict with already rendered output, e.g. by displaying HTML markup in an XML or JSON request. Props spacedmonkey, flixos90, TimothyBlynJacobs. Fixes #45989. See #44458. Built from https://develop.svn.wordpress.org/trunk@45014 git-svn-id: http://core.svn.wordpress.org/trunk@44823 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6b6201ed89
commit
3f6a9eb0e3
@ -26,11 +26,6 @@ class WP_Fatal_Error_Handler {
|
||||
* @since 5.2.0
|
||||
*/
|
||||
public function handle() {
|
||||
// Bail if WordPress executed successfully.
|
||||
if ( defined( 'WP_EXECUTION_SUCCEEDED' ) && WP_EXECUTION_SUCCEEDED ) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Bail if no error found.
|
||||
$error = $this->detect_error();
|
||||
@ -42,8 +37,10 @@ class WP_Fatal_Error_Handler {
|
||||
wp_recovery_mode()->handle_error( $error );
|
||||
}
|
||||
|
||||
// Display the PHP error template.
|
||||
$this->display_error_template();
|
||||
// Display the PHP error template if headers not sent.
|
||||
if ( ! headers_sent() ) {
|
||||
$this->display_error_template();
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
// Catch exceptions and remain silent.
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.2-alpha-45004';
|
||||
$wp_version = '5.2-alpha-45014';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
@ -544,12 +544,3 @@ if ( is_multisite() ) {
|
||||
* @since 3.0.0
|
||||
*/
|
||||
do_action( 'wp_loaded' );
|
||||
|
||||
/*
|
||||
* Store the fact that we could successfully execute the entire WordPress
|
||||
* lifecycle. This is used to skip the premature shutdown handler, as it cannot
|
||||
* be unregistered.
|
||||
*/
|
||||
if ( ! defined( 'WP_EXECUTION_SUCCEEDED' ) ) {
|
||||
define( 'WP_EXECUTION_SUCCEEDED', true );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user