admin管理员组

文章数量:1327980

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 :)

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 :)

Share Improve this question edited Jun 10, 2019 at 15:16 fuxia 107k38 gold badges255 silver badges459 bronze badges asked Jun 10, 2019 at 14:43 MilanMilan 351 silver badge5 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 7

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 );

Very detailed answer by Jacob Peattie and I would +1 that for sure. I'd also like to add that you can use the following ini_set commands and also specify your debug log location.

@ini_set('log_errors','On'); // This is essentialy what ('WP_DEBUG', true) does.
@ini_set('display_errors','Off'); // Avoid the ugly display of errors on live sites.
@ini_set('error_log','/home/domain/logs/php_error.log'); // Set your log path.

本文标签: WPDISABLEFATALERRORHANDLER vs WPDEBUGWhat to use and when to use to see errors