Opened 4 years ago
Closed 4 years ago
#49959 closed enhancement (fixed)
Introduce a new helper function to check if WordPress is currently in maintenance mode
Reported by: | Clorith | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.5 | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | Upgrade/Install | Keywords: | has-patch 2nd-opinion |
Focuses: | Cc: |
Description
Initially thought of as wp_is_updating()
, but as I've spent some time considering this, maintenance mode is used by various plugins as well, so it seems reasonable to instead go with something along the lines of wp_is_maintenance_mode()
, returning a boolean to indicate if maintenance mode is enabled or not.
Currently core only checks for maintenance mode in a single location, in the `wp_maintenance()` function, used to stop processing if maintenance is ongoing.
With #48964 also looking to check if maintenance mode is enabled, it makes sense to split this out, both for core, but also for potential maintenance plugins.
The most direct route would be to take parts of the existing function, and make that the new helper, specifically lines 189-216.
The big question really is, what would such a function be named, to easily convey intent.
For completeness sake, there is already a wp_installing()
boolean check, which looks for the setup constants. With the existing function being there wit ha similar name, it seemed more appropriate to give the new one a slightly more descriptive function name.
Attachments (1)
Change History (8)
#1
follow-up:
↓ 6
@
4 years ago
- Keywords has-patch added
- Milestone changed from Awaiting Review to 5.5
This ticket was mentioned in Slack in #core by clorith. View the logs.
4 years ago
#3
@
4 years ago
If a site is in maintenance mode any other request is blocked which means the function can’t be used by something else. Am I missing something?
#4
@
4 years ago
While this is true that regular requests will not be able to process, the fatal error handler is still active, and can trigger email notifications during race conditions where files are being processed.
I plan on adding a maintenance check to avoid the error handler from triggering during upgrade routines in #48964, hence this pre-requisite to avoid duplicating the check for .maintenance
and related checks that are done.
#5
@
4 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 47623:
#6
in reply to:
↑ 1
@
4 years ago
- Keywords 2nd-opinion added
- Resolution fixed deleted
- Status changed from closed to reopened
Replying to Clorith:
49959.patch implements the proposed function, using the name
wp_in_maintenance_mode()
, as it checks the state, so the use ofis
might have ended up being confusing to some.
It occurred to me that we already have wp_is_recovery_mode() and wp_is_fatal_error_handler_enabled().
Perhaps wp_is_maintenance_mode()
or wp_is_maintenance_mode_enabled()
would be a better name for consistency with those two functions? I'm not 100% sure the existing name from [47623] should be changed, just wanted to bring it up for discussion.
49959.patch implements the proposed function, using the name
wp_in_maintenance_mode()
, as it checks the state, so the use ofis
might have ended up being confusing to some.