Make WordPress Core


Ignore:
Timestamp:
09/15/2021 06:39:09 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Upgrade/Install: Create a temporary backup of plugins and themes before updating.

This aims to make the update process more reliable and ensures that if a plugin or theme update fails, the previous version can be safely restored.

  • When updating a plugin or theme, the old version is moved to a temporary backup directory:
    • wp-content/upgrade/temp-backup/plugins/[plugin-slug] for plugins
    • wp-content/upgrade/temp-backup/themes/[theme-slug] for themes.
  • If the update fails, then the temporary backup kept in the upgrade/temp-backup directory is restored to its original location.
  • If the update succeeds, the temporary backup is deleted.

To further help troubleshoot plugin and theme updates, two new checks were added to the Site Health screen:

  • A check to make sure that the temp-backup directory is writable.
  • A check that there is enough disk space available to safely perform updates.

To avoid confusion: The temp-backup directory will NOT be used to "roll back" a plugin to a previous version after a completed update. This directory will simply contain a transient backup of the previous version of a plugin or theme being updated, and as soon as the update process finishes, the directory will be empty.

Props aristath, afragen, pbiron, dd32, poena, TimothyBlynJacobs, audrasjb, mikeschroder, a2hosting, hellofromTonya, KZeni, galbaras, richards1052, Boniu91, mai21, francina, SergeyBiryukov.
See #51857.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-plugin-upgrader.php

    r51528 r51815  
    227227                'clear_working'     => true,
    228228                'hook_extra'        => array(
    229                     'plugin' => $plugin,
    230                     'type'   => 'plugin',
    231                     'action' => 'update',
     229                    'plugin'      => $plugin,
     230                    'type'        => 'plugin',
     231                    'action'      => 'update',
     232                    'temp_backup' => array(
     233                        'slug' => dirname( $plugin ),
     234                        'src'  => WP_PLUGIN_DIR,
     235                        'dir'  => 'plugins',
     236                    ),
    232237                ),
    233238            )
     
    343348                    'is_multi'          => true,
    344349                    'hook_extra'        => array(
    345                         'plugin' => $plugin,
     350                        'plugin'      => $plugin,
     351                        'temp_backup' => array(
     352                            'slug' => dirname( $plugin ),
     353                            'src'  => WP_PLUGIN_DIR,
     354                            'dir'  => 'plugins',
     355                        ),
    346356                    ),
    347357                )
Note: See TracChangeset for help on using the changeset viewer.