Opened 20 months ago

Last modified 20 months ago

#18826 new enhancement

wp_maintenance() expiration time needs to be filterable

Reported by: jaredh123 Owned by:
Priority: normal Milestone: Awaiting Review
Component: Upgrade/Install Version: 3.3
Severity: normal Keywords: 2nd-opinion
Cc:

Description

.maintenance files expire after 10 minutes if something goes wrong. 10 minutes is a long time, when most upgrading operations are attempted and fail within 20-60 seconds.

I propose three things:

  1. changing the default expiration to 5 minutes (300 seconds)
  2. Adding a filter to allow plugins and themes to filter this time to increase/decrease it
  3. Also, while I was in there, it seems prudent to attempt to delete the file if it has expired. The only argument I could see against this is that possibly it might be expensive if the file can not be deleted and wp attempts to delete the file on every page load. So I can take or leave 3 (and 2), but #2 I think is really important.

Attachments (1)

maintenance.diff (613 bytes) - added by jaredh123 20 months ago.

Download all attachments as: .zip

Change History (2)

  • Keywords 2nd-opinion added; has-patch removed

Adding a filter to allow plugins and themes to filter this time to increase/decrease it

Can't be done there, apply_filters() isn't even loaded yet, and Plugins definitely aren't loaded. Any filtering would have to be on the $time value stored within the .maintainence file itself.

Also, while I was in there, it seems prudent to attempt to delete the file if it has expired.

The main reason that wouldn't be done already, is the fact that not all servers have write access to the directory, would ultimately mean attempting to delete it on every page load.

Deleting the file isn't too much of a problem IMO, given once it's expired it'll skip through that section of code anyway. It'll just get cleaned up the next time an upgrade is attempted otherwise.

changing the default expiration to 5 minutes (300 seconds)

As bad as this sounds: The reason it's set to 10 minutes, is because while most upgrades complete within a few minutes and clean the file up once done, not all do, I've seen a few hosts take >5 minutes for upgrades.

Clearing the timeout too early will cause the site to come back online before the process has finished for some people (the whole reason the maintainence file is there).

The majority of failed install attempts should clear the maintainence lock when it detects a failure, of course, if PHP is simply shut down completely mid-load, there's not much it can do - same for when the FTP connection dies and doesn't reconnect for some.

Note: See TracTickets for help on using tickets.