[wp-trac] [WordPress Trac] #51857: Add rollback for failed plugin/theme updates

WordPress Trac noreply at wordpress.org
Mon Aug 30 09:59:48 UTC 2021


#51857: Add rollback for failed plugin/theme updates
----------------------------------------------+-----------------------
 Reporter:  pbiron                            |       Owner:  pbiron
     Type:  enhancement                       |      Status:  reopened
 Priority:  normal                            |   Milestone:  5.9
Component:  Upgrade/Install                   |     Version:
 Severity:  normal                            |  Resolution:
 Keywords:  early has-patch has-testing-info  |     Focuses:
----------------------------------------------+-----------------------

Comment (by aristath):

 Replying to feedback/questions on
 https://core.trac.wordpress.org/ticket/51857#comment:102

 > Question related to 2nd point:
 > Is this function 100% reliable in all environments?

 I searched and didn't find any gotchas for that function... I haven't
 tested it on all environments because I only have access to a limited pool
 of testing environments.
 That being said, if the `disk_free_space` function can't get a proper
 result it returns `false`, in which case the message shown to users in
 site-health is `Could not determine available disk space for updates.`

 > If we change permissions of `/upgrade/temp-backup/plugins/plugin_name/`
 it won't be possible to update the plugin `plugin_name` anymore. It will
 end up with error:
 > `Could not move old version to the temp-backup directory.`
 > There's no message inside the Site Health section about that. I think we
 could add kind of check, that would display a notice when `/upgrade/temp-
 backup/plugins/` or `/upgrade/temp-backup/themes/` are not empty and error
 when their content is not writeable.

 The only problem with that is the fact that there is a chance an update is
 running at the same time... Maybe an automatic-update is triggered on the
 background, or we have 2 tabs open to do multiple tasks at once and we're
 updating plugins on another tab, or maybe the site has multiple admins and
 someone else is running an update at the same time.
 I agree that ideally we'd have that message, but at this stage I don't see
 how we can safely do it without false-positives. It would be possible if
 there was a function like `is_currently_updating()` which would allow us
 to check if there's an update currently in progress, but so far I haven't
 found a way to do that efficiently.

 ----------
 Replying to questions from
 https://core.trac.wordpress.org/ticket/51857#comment:103

 > 1- How to do the needed prequest of server size?

 That one is tricky... The easiest solution would be to edit this line:
 {{{#!php
 if ( 20 > $available_space_in_mb ) {
 }}}
 and replace the number `20` with something like `200000` (or some other
 value depending on how much disk space you have available on your machine)
 to make sure the error gets properly triggered when the defined number is
 larger than the available disk-space.

 > 2- What is exactly expected with failure of upgrade regarding backup
 file? is it ever added to the upgrade folder?

 If the failure happens while downloading the update, then the backup is
 never created, it fails before we get to the backup step
 If the backup fails for some reason like file/folder permissions, low disk
 space etc, then the backup gets restored to the plugin's original
 location. So on failure the backup folder will be empty, but the original
 plugin will be restored (as opposed to the previous behavior which had the
 plugin removed or in some cases half-installed)

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/51857#comment:109>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list