• Hey,

    I try to check via code whether the fatal error handler is switched on or off. But if I use true or false with the add_filter, it makes no difference with the control code below.

    /**
     * Disable the fatal error handler.
     */
    add_filter( 'wp_fatal_error_handler_enabled', '__return_false' );
    
    $err = "Some plugin or theme are causing WSOD, Contact webmaster!";
    $ok = "No problem !";
    echo wp_is_recovery_mode() ? "$err" : "$ok";

    Thank you in advance!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator bcworkz

    (@bcworkz)

    Try adding to wp-config.php:
    define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true );

    Add near the bottom, just above the line:
    /* That's all, stop editing! Happy blogging. */

    Thread Starter crslz

    (@crslz)

    Hi,

    I already know that function, I want to do it via code from a self-written plugin.

    Have you tried WP_DEBUG on false?
    For example https://core.trac.wordpress.org/attachment/ticket/46825/46825.2.patch
    https://core.trac.wordpress.org/ticket/46825

    • This reply was modified 4 years, 6 months ago by autotutorial.

    https://github.com/WordPress/WordPress/blob/master/wp-includes/load.php#L810

    The use of the arrow (->) is an OOP construct to access the properties and methods contained in a given object:

    call object with properties is_initialized or is_active.

    Thread Starter crslz

    (@crslz)

    Hi,

    If I use this

    adding to wp-config.php:
    define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true );

    or this

    theme’s functions.php file add the following line:
    add_filter( ‘wp_fatal_error_handler_enabled’, ‘__return_false’ );

    It makes no difference, it both doesn’t work.

    I think I have found the problem but can someone confirm this? My local test installation (Ampss) uses php 7.1 and I think that for the above functions php 7.2 is required, could this be correct?

    I have no possibility to test this with a higher php version because Ampps has no update yet.

    Thread Starter crslz

    (@crslz)

    @autotutorial

    I could find this about it

    ‘Setting the WP_DEBUG as true will not disable the WSOD protection. This is by design’. However, when using WP_DEBUG on false and

    add_filter( ‘wp_fatal_error_handler_enabled’, ‘__return_false’ );

    This seems to make no difference, I think the function is not working properly or it is the use of the php version (see my previous message)

    Moderator bcworkz

    (@bcworkz)

    The code involved has little bearing on PHP version. WP will work in any version equal to or later than 5.6.20.

    I hope your code is using proper syntax and not the “curly” quotes in your posted snippet 🙂

    It could be a plugin is overriding your filter. Try adding with a large priority argument:
    add_filter( 'wp_fatal_error_handler_enabled', '__return_false', PHP_INT_MAX );

    If you are using a WP version that is host provided, such as from a one click install or a managed WP package, some hosts modify WP core for their environment. If this is the case, disabling the error handler could prove to be difficult.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Disable the fatal error handler’ is closed to new replies.