#50134 closed enhancement (fixed)
wp_fatal_error_handler_enabled doesn't actually do anything
Reported by: | programmin | Owned by: | johnbillion |
---|---|---|---|
Milestone: | 5.6 | Priority: | normal |
Severity: | normal | Version: | 5.2 |
Component: | Site Health | Keywords: | |
Focuses: | docs | Cc: |
Description
Suppose you want to turn off the error handling... Try this in a mu-plugin:
<?php function somethingg() { echo 'my code runs'; return false; } somethingg(); add_filter( 'wp_fatal_error_handler_enabled', 'somethingg' );
And add this to error-protection.php WP:
<?php function wp_register_fatal_error_handler() { if ( ! wp_is_fatal_error_handler_enabled() ) { return; } echo 'FATAL HANDLER = TRUE';
Now if you get an error (eg new NoneClass()) you will get the output:
FATAL HANDLER = TRUEmy code runs
There has been a critical error on your website. Please check your site admin email inbox for instructions.
So the filter apparently never is seen because the handler runs before the add_filter even had a chance to set it.
Change History (6)
#1
follow-up:
↓ 2
@
4 years ago
- Component changed from General to Site Health
- Keywords dev-feedback added
- Version changed from 5.4.1 to 5.2
#2
in reply to:
↑ 1
@
4 years ago
- Focuses docs added
Replying to johnbillion:
I believe the intention of this filter is that it can only be used before WordPress initialises, for example by constructing the
$wp_filter
array insidewp-config.php
.
That's my understanding too, as it runs too early to be used in a "normal" way. If that's the case, it could use a better documentation.
#3
@
4 years ago
add_filter only works if WP is up? So yes if there is a specific way to do this then documentation should really show that the filter doesn't actually work, doesn't work like all the others work.
I believe the intention of this filter is that it can only be used before WordPress initialises, for example by constructing the
$wp_filter
array insidewp-config.php
. @schlessera might be able to confirm this.