1

After introduction of WP_DISABLE_FATAL_ERROR_HANDLER I'm confused with existing WP_DEBUG feature. Now what's the difference here?

I mean what constant I should use to see the error if I use WP_DISABLE_FATAL_ERROR_HANDLER then what's the meaning of WP_DEBUG now?

Even though I went through some of tickets on WordPress but I can't figure out the use of WP_DEBUG now.

Did WordPress ends the use of WP_DEBUG ?
After introduction of new constant WP_DISABLE_FATAL_ERROR_HANDLER I'm not able to see errors anymore with define("WP_DEBUG",true).
I know about display_errors setting in php.ini so not expecting this solution :)

1

Those constants do different things.

  • The WP_DISABLE_FATAL_ERROR_HANDLER constant is for disabling the new fatal error recovery feature introduced in WordPress 5.2. This new feature ensures that fatal errors from plugins don't lock you out of your site, and that front-end users get some kind of "technical difficulties" message, rather than a white screen.
  • The WP_DEBUG constant is to enable a debug mode that displays all PHP error messages and warnings on the front-end, as well as WordPress specific messages such as deprecation notices.

So you can see that they are not really related. The fatal error recovery functionality is intended to be used in production, so that white screens and PHP error messages are not displayed to users. While debug mode is intended to be used in a development environment to debug issues when developing a theme or plugin.

In a production environment (so a live site), neither constant should be enabled. Fatal error recovery should be enabled, and debug mode should be disabled.

In a development environment, you probably don't need fatal error recovery, and you'll likely want debug mode to be enabled.

If for some reason you need to debug issues on a live site, then debug mode might need to be enabled, but in that case you should have WP_DEBUG_DISPLAY set to false, and WP_DEBUG_LOG set to true, so that you can debug error messages from a log file, rather than exposing them to users.

So in a development environment you probably want:

define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true );
define( 'WP_DEBUG', true );

And in a production environment you probably want (these would be the same as not manually defining them):

define( 'WP_DISABLE_FATAL_ERROR_HANDLER', false );
define( 'WP_DEBUG', false );

And if you need to debug a live site you could use:

define( 'WP_DISABLE_FATAL_ERROR_HANDLER', false );
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'WP_DEBUG_LOG', true );
  • Thank you for the detailed answer. My doubt is cleared now:) – Milan Jun 10 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.