Make WordPress Core

Opened 18 months ago

Closed 15 months ago

Last modified 15 months ago

#56848 closed enhancement (fixed)

Avoid initializing WP_Recovery_Mode when fatal error handler is disabled

Reported by: flixos90's profile flixos90 Owned by: flixos90's profile flixos90
Milestone: 6.2 Priority: normal
Severity: normal Version: 5.2
Component: Site Health Keywords: has-patch reporter-feedback
Focuses: Cc:

Description

#44458 and #46130 introduced the fatal error handler that sends an email to the admin to enter a recovery mode.

Since the initial implementation, there have been a constant WP_DISABLE_FATAL_ERROR_HANDLER and a filter wp_fatal_error_handler_enabled which can be used to disable the fatal error handler.

However, as of today the recovery mode logic in the WP_Recovery_Mode is still being initialized even when the fatal error handler is disabled. This does not raise any functional concerns, but it should not be necessary given the fatal error handler that can trigger recovery mode is disabled. By removing it, we avoid running unnecessary logic and an early lookup of the "cron" database option.

We should amend the clause in wp-settings.php around the call that initializes the WP_Recovery_Mode class with an extra condition for wp_is_fatal_error_handler_enabled().

Change History (10)

This ticket was mentioned in Slack in #core by mukeshpanchal27. View the logs.


15 months ago

#2 @mukesh27
15 months ago

This ticket was discussed in the recent bug scrub.

Need a patch for it to help it move forward.

Props to @costdev

This ticket was mentioned in PR #3898 on WordPress/wordpress-develop by @costdev.


15 months ago
#3

  • Keywords has-patch added; needs-patch removed

This PR adds a wp_is_fatal_error_handler_enabled() condition before initializing recovery mode.

Trac ticket: https://core.trac.wordpress.org/ticket/56848

#4 @costdev
15 months ago

  • Keywords reporter-feedback added

@flixos90 I've submitted PR 3898 which adds wp_is_fatal_error_handler_enabled() to the conditions before initializing recovery mode.

Regarding needs-unit-tests, as this change is in wp-settings.php, which is loaded in the test suite's bootstrap, I'm not sure whether PHPUnit tests are possible for this. What do you think?

#5 @costdev
15 months ago

  • Version set to 5.2

Original condition block introduced in [44973]. Setting Version to 5.2.

#6 @flixos90
15 months ago

Thanks @costdev for the patch. I agree with you that unfortunately we can't reasonably write tests for this. I think this is good to go as is.

#7 @flixos90
15 months ago

  • Owner set to flixos90
  • Status changed from new to reviewing

#8 @flixos90
15 months ago

  • Keywords needs-unit-tests removed

#9 @flixos90
15 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 55143:

Bootstrap/Load: Avoid initializing WP_Recovery_Mode when fatal error handler is disabled.

The WordPress recovery mode only works in combination with the fatal error handler that works as the entry mode for recovery mode. The fatal error handler can be disabled using the WP_DISABLE_FATAL_ERROR_HANDLER constant, but so far the logic in the WP_Recovery_Mode class was still being initialized even when that constant was set to true, which is unnecessary.

This changeset updates the WordPress bootstrap process to only initialize WP_Recovery_Mode when needed.

Props costdev.
Fixes #56848.

Note: See TracTickets for help on using tickets.