WordPress.org

Make WordPress Core

Opened 20 months ago

Closed 19 months ago

Last modified 19 months 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 20 months ago.
49400.1.patch (5.1 KB) - added by dkarfa 20 months ago.
49400.2.patch (5.5 KB) - added by bookdude13 19 months ago.
Docs added for themes file as well

Download all attachments as: .zip

Change History (24)

#1 @desrosj
20 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
20 months ago

  • Milestone changed from Awaiting Review to 5.4

@desrosj
20 months ago

@dkarfa
20 months ago

#3 @SergeyBiryukov
20 months 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
20 months 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
20 months 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
19 months 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
19 months ago

Docs added for themes file as well

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


19 months ago

#8 @garrett-eclipse
19 months 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.


19 months ago

#10 @johnbillion
19 months ago

  • Keywords revert added

#11 @desrosj
19 months 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
19 months ago

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

Last edited 19 months ago by desrosj (previous) (diff)

#13 @afragen
19 months 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
19 months 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
19 months ago

In 47409:

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

Props bookdude13

See #49400

#16 @johnbillion
19 months ago

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

#17 in reply to: ↑ 15 @bookdude13
19 months 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
19 months ago

Hey @bookdude13
Thank you
Debabrata

#19 @johnbillion
19 months 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
19 months ago

In 47414:

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

See #49400.

#21 @dkarfa
19 months ago

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

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