diff --git a/src/wp-includes/class-wp-fatal-error-handler.php b/src/wp-includes/class-wp-fatal-error-handler.php index e469497af3..fa189cc57d 100644 --- a/src/wp-includes/class-wp-fatal-error-handler.php +++ b/src/wp-includes/class-wp-fatal-error-handler.php @@ -39,7 +39,7 @@ class WP_Fatal_Error_Handler { // Display the PHP error template if headers not sent. if ( ! headers_sent() ) { - $this->display_error_template(); + $this->display_error_template( $error ); } } catch ( Exception $e ) { // Catch exceptions and remain silent. @@ -117,8 +117,10 @@ class WP_Fatal_Error_Handler { * If no such drop-in is available, this will call {@see WP_Fatal_Error_Handler::display_default_error_template()}. * * @since 5.2.0 + * + * @param array $error Error information retrieved from `error_get_last()`. */ - protected function display_error_template() { + protected function display_error_template( $error ) { if ( defined( 'WP_CONTENT_DIR' ) ) { // Load custom PHP error template, if present. $php_error_pluggable = WP_CONTENT_DIR . '/php-error.php'; @@ -130,7 +132,7 @@ class WP_Fatal_Error_Handler { } // Otherwise, display the default error template. - $this->display_default_error_template(); + $this->display_default_error_template( $error ); } /** @@ -143,8 +145,10 @@ class WP_Fatal_Error_Handler { * be used to modify these parameters. * * @since 5.2.0 + * + * @param array $error Error information retrieved from `error_get_last()`. */ - protected function display_default_error_template() { + protected function display_default_error_template( $error ) { if ( ! function_exists( '__' ) ) { wp_load_translations_early(); } @@ -166,8 +170,9 @@ class WP_Fatal_Error_Handler { * @since 5.2.0 * * @param string $message HTML error message to display. + * @param array $error Error information retrieved from `error_get_last()`. */ - $message = apply_filters( 'wp_php_error_message', $message ); + $message = apply_filters( 'wp_php_error_message', $message, $error ); /** * Filters the arguments passed to {@see wp_die()} for the default PHP error template. @@ -176,11 +181,14 @@ class WP_Fatal_Error_Handler { * * @param array $args Associative array of arguments passed to `wp_die()`. By default these contain a * 'response' key, and optionally 'link_url' and 'link_text' keys. + * @param array $error Error information retrieved from `error_get_last()`. */ - $args = apply_filters( 'wp_php_error_args', $args ); + $args = apply_filters( 'wp_php_error_args', $args, $error ); - $error = new WP_Error( 'internal_server_error', $message ); + $wp_error = new WP_Error( 'internal_server_error', $message, array( + 'error' => $error, + ) ); - wp_die( $error, '', $args ); + wp_die( $wp_error, '', $args ); } }