WordPress.org

Make WordPress Core

Opened 2 months ago

Closed 5 weeks ago

Last modified 5 weeks ago

#49400 closed enhancement (fixed)

Enable maintenance mode when a plugin auto-updates

Reported by: desrosj Owned by: desrosj
Milestone: 5.4 Priority: normal
Severity: normal Version:
Component: Upgrade/Install Keywords: has-patch
Focuses: docs Cc:

Description

Currently, when an active plugin is auto-updating, it remains active and the site does not enter maintenance mode.

This can cause a few issues:

  • If a user loads the Plugins screen in the admin, the plugin could deactivate if an error is encountered mid upgrade.
  • If a user loads the front end of the website and an error is encountered, the WSOD protection will be triggered sending a "false alarm" email to the site admin.

This is a spin-off of #48850 to tackle this in a smaller chunk.

Also potentially related: #34676.

Attachments (3)

49400.diff (3.3 KB) - added by desrosj 2 months ago.
49400.1.patch (5.1 KB) - added by dkarfa 8 weeks ago.
49400.2.patch (5.5 KB) - added by bookdude13 6 weeks ago.
Docs added for themes file as well

Download all attachments as: .zip

Change History (24)

#1 @desrosj
2 months ago

  • Keywords needs-testing added

49400.diff uses the same approach that is used in the Theme_Upgrader class, hooking into the pre-install/post-install filters.

#2 @desrosj
2 months ago

  • Milestone changed from Awaiting Review to 5.4

@desrosj
2 months ago

@dkarfa
8 weeks ago

#3 @SergeyBiryukov
8 weeks ago

The documentation fixes in 49400.1.patch look good at a glance, but I'd like to make sure they're consistent with class-theme-upgrader.php.

Let's get 49400.diff in for now, and improve the docs after Beta 1.

#4 @desrosj
8 weeks ago

  • Owner set to desrosj
  • Resolution set to fixed
  • Status changed from new to closed

In 47275:

Upgrade/Install: Enable maintenance mode when plugins are auto-updated.

When an attempt is made to update an active plugin automatically, there is the potential currently for two negative scenarios:

  • The plugin can be deactivated if the Plugins admin screen is loaded when the plugin update is incomplete, causing a PHP error.
  • The WSOD protection could be triggered, sending a false alarm email to the site administrator.

By enabling maintenance mode before an active plugin update is attempted, these scenarios can be avoided.

This change implements the same approach as the Theme_Upgrader class of using the upgrader_pre_install and upgrader_post_install hooks to toggle maintenance mode.

Props desrosj, SergeyBiryukov.
Fixes #49400.

#5 @desrosj
8 weeks ago

  • Focuses docs added
  • Keywords needs-testing removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening to improve the inline documentation during beta.

#6 @bookdude13
6 weeks ago

Inline docs checked, slightly reformatted, and applied to the functions in class-theme-upgrader.php as well.

Side question, is there a reason the filters in class-plugin-upgrader.php's bulk_update() are different than update(), but in class-theme-upgrader.php they are the same?

@bookdude13
6 weeks ago

Docs added for themes file as well

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


6 weeks ago

#8 @garrett-eclipse
6 weeks ago

@desrosj / @SergeyBiryukov
With auto-updates on plugins (#48850) having moved to 5.5 and the feature plugin should commit [47275] be reverted and this moved to the 5.5 milestone to align with the auto-updates functionality?

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


5 weeks ago

#10 @johnbillion
5 weeks ago

  • Keywords revert added

#11 @desrosj
5 weeks ago

Personally, I don’t feel this needs to be reverted. This is a self-contained enhancement to plugin auto-updates. While this feature has not been exposed through a UI in 5.4, site owners can still enable this with a filter.

On my personal sites, I have been seeing this work without issue since the day it was committed. I receive debug emails, and maintenance mode is correctly toggled before and after update.

If there is consensus to make all auto-update improvements in the same release, I’m fine with reverting. But this one is not coupled to the UI aspects, and will only prevent the two scenarios in the ticket description.

#12 @desrosj
5 weeks ago

That said, the documentation does still need to be updated.

Last edited 5 weeks ago by desrosj (previous) (diff)

#13 @afragen
5 weeks ago

How does this effect premium plugins or plugins not on dot org that contain their own updating code?

Deactivating them in the middle of an update could be very problematic.

#14 @johnbillion
5 weeks ago

  • Keywords revert removed

This doesn't deactivate anything, it puts the site into maintenance mode (via wp_maintenance()).

@desrosj In that case I'm happy to leave the code in place. The revert was more to remove non-functional code, but if this can be utilised by plugins then I'm happy for it to stay in.

I'll review the docs changes and get those in.

#15 follow-up: @johnbillion
5 weeks ago

In 47409:

Upgrade/Install: Improved inline docs for the plugin and theme updater maintenance mode functionality.

Props bookdude13

See #49400

#16 @johnbillion
5 weeks ago

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

#17 in reply to: ↑ 15 @bookdude13
5 weeks ago

@dkarfa should get props too, I mostly reformatted what he had already put in for docs.
Replying to johnbillion:

Props bookdude13

See #49400
}}}

#18 @dkarfa
5 weeks ago

Hey @bookdude13
Thank you
Debabrata

#19 @johnbillion
5 weeks ago

Apologies @dkarfa , my mistake.

I checked and as you've already gotten props on other changes in this release, you'll definitely be on the credits list for 5.4.

#20 @SergeyBiryukov
5 weeks ago

In 47414:

Docs: Correct formatting of some DocBlocks in Plugin_Upgrader and Theme_Upgrader per the documentation standards.

See #49400.

#21 @dkarfa
5 weeks ago

Much obliged @johnbillion . May be the quantity of check will be less.

Last edited 5 weeks ago by dkarfa (previous) (diff)
Note: See TracTickets for help on using tickets.