On this page
WP_Recovery_Mode::handle_error( array $error ): true|WP_Error
Handles a fatal error occurring.
Description
The calling API should immediately die() after calling this function.
Parameters
$errorarray Required-
Error details from
error_get_last().
Return
true|WP_Error True if the error was handled and headers have already been sent.
Or the request will exit to try and catch multiple errors at once.
WP_Error if an error occurred preventing it from being handled.
Source
File: wp-includes/class-wp-recovery-mode.php. View all references
public function handle_error( array $error ) {
$extension = $this->get_extension_for_error( $error );
if ( ! $extension || $this->is_network_plugin( $extension ) ) {
return new WP_Error( 'invalid_source', __( 'Error not caused by a plugin or theme.' ) );
}
if ( ! $this->is_active() ) {
if ( ! is_protected_endpoint() ) {
return new WP_Error( 'non_protected_endpoint', __( 'Error occurred on a non-protected endpoint.' ) );
}
if ( ! function_exists( 'wp_generate_password' ) ) {
require_once ABSPATH . WPINC . '/pluggable.php';
}
return $this->email_service->maybe_send_recovery_mode_email( $this->get_email_rate_limit(), $error, $extension );
}
if ( ! $this->store_error( $error ) ) {
return new WP_Error( 'storage_error', __( 'Failed to store the error.' ) );
}
if ( headers_sent() ) {
return true;
}
$this->redirect_protected();
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Recovery_Mode::get_extension_for_error() wp-includes/class-wp-recovery-mode.php | Gets the extension that the error occurred in. |
| WP_Recovery_Mode::is_network_plugin() wp-includes/class-wp-recovery-mode.php | Checks whether the given extension a network activated plugin. |
| WP_Recovery_Mode::store_error() wp-includes/class-wp-recovery-mode.php | Stores the given error so that the extension causing it is paused. |
| WP_Recovery_Mode::redirect_protected() wp-includes/class-wp-recovery-mode.php | Redirects the current request to allow recovering multiple errors in one go. |
| WP_Recovery_Mode::is_active() wp-includes/class-wp-recovery-mode.php | Checks whether recovery mode is active. |
| WP_Recovery_Mode::get_email_rate_limit() wp-includes/class-wp-recovery-mode.php | Gets the rate limit between sending new recovery mode email links. |
| is_protected_endpoint() wp-includes/load.php | Determines whether we are currently on an endpoint that should be protected against WSODs. |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| WP_Error::__construct() wp-includes/class-wp-error.php | Initializes the error. |
Used By
| Used By | Description |
|---|---|
| WP_Fatal_Error_Handler::handle() wp-includes/class-wp-fatal-error-handler.php | Runs the shutdown handler. |
Changelog
| Version | Description |
|---|---|
| 5.2.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_recovery_mode/handle_error