WP_Fatal_Error_Handler::display_default_error_template( array $error, true|WP_Error $handled )
- Since
- 5.2.0, 5.3.0
- Source
wp-includes/class-wp-fatal-error-handler.php:174
Description
This method is called conditionally if no 'php-error.php' drop-in is available.
It calls wp_die() with a message indicating that the site is experiencing technical difficulties and a login link to the admin backend. The 'wp_php_error_message' and 'wp_php_error_args' filters can be used to modify these parameters.
Compatibility
- WordPress
- since 5.3.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$errorarray- Error information retrieved from
error_get_last(). $handledtrue|WP_Error- Whether Recovery Mode handled the fatal error.
Performance profile
How much work a call to WP_Fatal_Error_Handler::display_default_error_template() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 61–92
- Plugin surface
- 2 hooks
- Called by
- 1
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 106.
Third-party callbacks on 'wp_php_error_message', 'wp_php_error_args' run inside this call, and their cost is not bounded by anything here.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()called directly
Further down the call graph this can also reach query, option, cache, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 18 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Fatal_Error_Handler::display_default_error_template() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
function_exists() && $handled !== true && !is_protected_endpoint() | 61–71 | function_exists(), function_exists(), is_protected_endpoint(), __(), __(), __(), apply_filters(), apply_filters(), error(), wp_die() |
function_exists() && $handled === true && wp_is_recovery_mode() | 62–72 | function_exists(), function_exists(), wp_is_recovery_mode(), __(), __(), __(), apply_filters(), apply_filters(), error(), wp_die() |
!function_exists() && $handled !== true && !is_protected_endpoint() | 63–73 | function_exists(), wp_load_translations_early(), function_exists(), is_protected_endpoint(), __(), __(), __(), apply_filters(), apply_filters(), error(), wp_die() |
function_exists() && $handled === true && !wp_is_recovery_mode() && !is_protected_endpoint() | 64–74 | function_exists(), function_exists(), wp_is_recovery_mode(), is_protected_endpoint(), __(), __(), __(), apply_filters(), apply_filters(), error(), wp_die() |
!function_exists() && $handled === true && wp_is_recovery_mode() | 64–74 | function_exists(), wp_load_translations_early(), function_exists(), wp_is_recovery_mode(), __(), __(), __(), apply_filters(), apply_filters(), error(), wp_die() |
function_exists() && $handled !== true && is_protected_endpoint() && !->is_initialized() | 66–76 | function_exists(), function_exists(), is_protected_endpoint(), wp_recovery_mode(), ->is_initialized(), __(), __(), __(), apply_filters(), apply_filters(), error(), wp_die() |
!function_exists() && $handled === true && !wp_is_recovery_mode() && !is_protected_endpoint() | 66–76 | function_exists(), wp_load_translations_early(), function_exists(), wp_is_recovery_mode(), is_protected_endpoint(), __(), __(), __(), apply_filters(), apply_filters(), error(), wp_die() |
!function_exists() && $handled !== true && is_protected_endpoint() && !->is_initialized() | 68–78 | function_exists(), wp_load_translations_early(), function_exists(), is_protected_endpoint(), wp_recovery_mode(), ->is_initialized(), __(), __(), __(), apply_filters(), apply_filters(), error(), wp_die() |
function_exists() && $handled === true && !wp_is_recovery_mode() && is_protected_endpoint() && !->is_initialized() | 69–79 | function_exists(), function_exists(), wp_is_recovery_mode(), is_protected_endpoint(), wp_recovery_mode(), ->is_initialized(), __(), __(), __(), apply_filters(), apply_filters(), error(), wp_die() |
function_exists() && $handled !== true && is_protected_endpoint() && ->is_initialized() && is_multisite() | 70–80 | function_exists(), function_exists(), is_protected_endpoint(), wp_recovery_mode(), ->is_initialized(), is_multisite(), __(), __(), __(), apply_filters(), apply_filters(), error(), wp_die() |
!function_exists() && $handled === true && !wp_is_recovery_mode() && is_protected_endpoint() && !->is_initialized() | 71–81 | function_exists(), wp_load_translations_early(), function_exists(), wp_is_recovery_mode(), is_protected_endpoint(), wp_recovery_mode(), ->is_initialized(), __(), __(), __(), apply_filters(), apply_filters(), error(), wp_die() |
!function_exists() && $handled !== true && is_protected_endpoint() && ->is_initialized() && is_multisite() | 72–82 | function_exists(), wp_load_translations_early(), function_exists(), is_protected_endpoint(), wp_recovery_mode(), ->is_initialized(), is_multisite(), __(), __(), __(), apply_filters(), apply_filters(), error(), wp_die() |
6 further outcomes, up to 92 instructions
function_exists() && $handled === true && !wp_is_recovery_mode() && is_protected_endpoint() && ->is_initialized() && is_multisite() | 73–83 | function_exists(), function_exists(), wp_is_recovery_mode(), is_protected_endpoint(), wp_recovery_mode(), ->is_initialized(), is_multisite(), __(), __(), __(), apply_filters(), apply_filters(), error(), wp_die() |
!function_exists() && $handled === true && !wp_is_recovery_mode() && is_protected_endpoint() && ->is_initialized() && is_multisite() | 75–85 | function_exists(), wp_load_translations_early(), function_exists(), wp_is_recovery_mode(), is_protected_endpoint(), wp_recovery_mode(), ->is_initialized(), is_multisite(), __(), __(), __(), apply_filters(), apply_filters(), error(), wp_die() |
function_exists() && $handled !== true && is_protected_endpoint() && ->is_initialized() && !is_multisite() | 77–87 | function_exists(), function_exists(), is_protected_endpoint(), wp_recovery_mode(), ->is_initialized(), is_multisite(), __(), __(), sprintf(), __(), __(), apply_filters(), apply_filters(), error(), wp_die() |
!function_exists() && $handled !== true && is_protected_endpoint() && ->is_initialized() && !is_multisite() | 79–89 | function_exists(), wp_load_translations_early(), function_exists(), is_protected_endpoint(), wp_recovery_mode(), ->is_initialized(), is_multisite(), __(), __(), sprintf(), __(), __(), apply_filters(), apply_filters(), error(), wp_die() |
function_exists() && $handled === true && !wp_is_recovery_mode() && is_protected_endpoint() && ->is_initialized() && !is_multisite() | 80–90 | function_exists(), function_exists(), wp_is_recovery_mode(), is_protected_endpoint(), wp_recovery_mode(), ->is_initialized(), is_multisite(), __(), __(), sprintf(), __(), __(), apply_filters(), apply_filters(), error(), wp_die() |
!function_exists() && $handled === true && !wp_is_recovery_mode() && is_protected_endpoint() && ->is_initialized() && !is_multisite() | 82–92 | function_exists(), wp_load_translations_early(), function_exists(), wp_is_recovery_mode(), is_protected_endpoint(), wp_recovery_mode(), ->is_initialized(), is_multisite(), __(), __(), sprintf(), __(), __(), apply_filters(), apply_filters(), error(), wp_die() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 106 | 61–92 | 8 | |
| 8.5 | 106 | 61–92 | 8 | |
| 8.4 | 106 | 61–92 | 8 | 1 fewer instruction than PHP 8.3 |
| 8.3 | 107 | 62–93 | 8 | |
| 8.2 | 107 | 62–93 | 8 | |
| 8.1 | 107 | 62–93 | 8 | |
| 7.4 | 107 | 62–93 | 8 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 2
2 hooks fire while WP_Fatal_Error_Handler::display_default_error_template() runs, in this order:
- apply_filters( wp_php_error_message )filterline 224 (+50 into the body)
Filters the message that the default PHP error template displays.
- apply_filters( wp_php_error_args )filterline 235 (+61 into the body)
Filters the arguments passed to {@see wp_die()} for the default PHP error template.
Uses · 10
- wp_load_translations_early()Attempts an early load of translations.
- wp_is_recovery_mode()Determines whether WordPress is in Recovery Mode.
- __()Retrieves the translation of $text.
- is_protected_endpoint()Determines whether we are currently on an endpoint that should be protected against WSODs.
- wp_recovery_mode()Access the WordPress Recovery Mode instance.
- is_multisite()Determines whether Multisite is enabled.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- wp_die()Kills WordPress execution and displays HTML page with an error message.
- wp_recovery_mode()::is_initialized()
- WP_Error::__construct()Initializes the error.
Used by · 1
- WP_Fatal_Error_Handler::display_error_template()Displays the PHP error template and sends the HTTP status code, typically 500.
Changelog
Introduced in 5.2.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
$handled parameter was added.from the docblockAbout this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/class-wp-fatal-error-handler.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.