Handling Fatal Errors Settings in WordPress Development Environments

Handling Fatal Errors Settings in WordPress Development Environments

WordPress version 5.2 introduced “Fatal Error Recovery Mode” which shows an error message to users as well as sends an email to the site administrator letting them know there was a fatal error.

While this is great for debugging – if you are actively developing on a development environment, there is no reason to show this message or get the email – especially if you are not the site admin. The development environment is used for development so that when and if you get any fatal errors, you see them right away and can address them.

I have seen issues with this especially when your client is the site admin. Your active development could trigger several emails which then cause concern for anyone who is not familiar with active development. The good news is that this feature is easy to disable in your development environment. Simply open up your wp-config.php file and add in the following line:


define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true );

This setting will ensure that the email notifications do not get sent and you can continue debugging/developing in your development environment.

One more thing…per the documentation, if you would like to keep the email in place but change who it goes to, you can add this to your functions.php file:

/**
 * Modify the recovery mode email address.
 */
add_filter( 'recovery_mode_email', function( $email ) {
    $email['to'] = 'admin@example.com';
    return $email;
} );

With that same filter – you can also change the email subject, message, headers and add an attachment.

Note – this Fatal Error Recovery Mode is very helpful in a production environment and should not be disabled.

Leave a Reply

Your email address will not be published.
*
*

This site uses Akismet to reduce spam. Learn how your comment data is processed.