#46047 closed enhancement (invalid)
Rename shutdown handler constant to allow it to be used for disabling it altogether
Reported by: | schlessera | Owned by: | flixos90 |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 5.1 |
Component: | Site Health | Keywords: | has-patch servehappy |
Focuses: | Cc: |
Description
As we cannot unregister the shutdown handler we register for the WSOD protection, we're currently defining a constant WP_EXECUTION_SUCCEEDED
to short-circuit its execution once WordPress has fully loaded.
This constant can actually be used to disable the shutdown handler altogether. Therefore, I suggest renaming it to WP_DISABLE_SHUTDOWN_HANDLER
so that its usage is more obvious.
Attachments (4)
Change History (21)
This ticket was mentioned in Slack in #core-php by schlessera. View the logs.
6 years ago
#4
@
6 years ago
Regardless of the name we choose, I suggest to add the WP_DISABLE_*
constant as an entirely new constant, in addition to WP_EXECUTION_SUCCEEDED
. While they are closely related, semantically they are not the same:
- One flags that WordPress has successfully loaded so that the shutdown handler should not run.
- One disables the shutdown handler entirely.
The new WP_DISABLE_*
would be purely for definition in wp-config.php
, and I suggest to put the check for it into the wp_register_premature_shutdown_handler()
function: If it is defined and true, don't even register any shutdown handler. This separates the two concerns and also allows mitigating the problem in #46038 easily, for example in a development setup.
This ticket was mentioned in Slack in #core-php by flixos90. View the logs.
6 years ago
#6
@
6 years ago
- Owner set to flixos90
- Status changed from new to assigned
46047.2.diff renames the WP_Shutdown_Handler
class to WP_Fatal_Error_Handler
and adjusts the drop-in name to fatal-error-handler.php
. It furthermore introduces a constant WP_DISABLE_FATAL_ERROR_HANDLER
to disable the handler entirely, and a filter wp_fatal_error_handler_enabled
to dynamically tweak that value.
These changes were discussed and agreed on in Slack today: https://wordpress.slack.com/archives/C60K3MP2Q/p1548090570493300
#7
@
6 years ago
46047.3.diff maintains the history correctly by using svn mv
, props @ocean90 :)
#9
@
6 years ago
While testing this, trying to add my own fatal error handler (fatal-error-handler.php), the defined( 'WP_CONTENT_DIR' )
check is always false (unless, of course, I define it directly in my wp-config.php file). Does that sound correct? If so, when documenting this option, should also document that defining it in your wp-config.php is important (at which point, why not allow defining the path to the custom fatal error handler directly??).
#10
@
6 years ago
I think this is because wp_initial_constants()
is not called until after wp_register_fatal_error_handler()
. The only meaningful changes between those two calls is the loading of the version file. It seems like it'd be fine to move the fatal error handler registration after that function call.
#11
@
6 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Yep, that seems like it would do the trick, and is better as then the various globals and constants will be available to the custom error handler (e.g. handle errors differently for versions of WP > X, for instance).
Regarding the naming, as we have multiple shutdown handler, this might still be misleading. A more precise name would be
WP_DISABLE_PREMATURE_SHUTDOWN_HANDLER
orWP_DISABLE_WSOD_PROTECTION
...