[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ -> class-wp-fatal-error-handler.php (summary)

Error Protection API: WP_Fatal_Error_Handler class

File Size: 243 lines (8 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 2 files
 wp-includes/functions.php
 wp-includes/class-wp-error.php

Defines 1 class

WP_Fatal_Error_Handler:: (5 methods):
  handle()
  detect_error()
  should_handle_error()
  display_error_template()
  display_default_error_template()


Class: WP_Fatal_Error_Handler  - X-Ref

Core class used as the default shutdown handler for fatal errors.

A drop-in 'fatal-error-handler.php' can be used to override the instance of this class and use a custom
implementation for the fatal error handler that WordPress registers. The custom class should extend this class and
can override its methods individually as necessary. The file must return the instance of the class that should be
registered.

handle()   X-Ref
Runs the shutdown handler.

This method is registered via `register_shutdown_function()`.


detect_error()   X-Ref
Detects the error causing the crash if it should be handled.

return: array|null Error information returned by `error_get_last()`, or null

should_handle_error( $error )   X-Ref
Determines whether we are dealing with an error that WordPress should handle
in order to protect the admin backend against WSODs.

param: array $error Error information retrieved from `error_get_last()`.
return: bool Whether WordPress should handle this error.

display_error_template( $error, $handled )   X-Ref
Displays the PHP error template and sends the HTTP status code, typically 500.

A drop-in 'php-error.php' can be used as a custom template. This drop-in should control the HTTP status code and
print the HTML markup indicating that a PHP error occurred. Note that this drop-in may potentially be executed
very early in the WordPress bootstrap process, so any core functions used that are not part of
`wp-includes/load.php` should be checked for before being called.

If no such drop-in is available, this will call {@see WP_Fatal_Error_Handler::display_default_error_template()}.

param: array         $error   Error information retrieved from `error_get_last()`.
param: true|WP_Error $handled Whether Recovery Mode handled the fatal error.

display_default_error_template( $error, $handled )   X-Ref
Displays the default PHP error template.

This method is called conditionally if no 'php-error.php' drop-in is available.

It calls {@see wp_die()} with a message indicating that the site is experiencing technical difficulties and a
login link to the admin backend. The {@see 'wp_php_error_message'} and {@see 'wp_php_error_args'} filters can
be used to modify these parameters.

param: array         $error   Error information retrieved from `error_get_last()`.
param: true|WP_Error $handled Whether Recovery Mode handled the fatal error.



Generated : Tue Mar 19 08:20:01 2024 Cross-referenced by PHPXref