All Projects → WordPress → rollback-update-failure

WordPress / rollback-update-failure

Licence: MIT License
Feature plugin to test zip rollback of plugin/theme update failures.

Programming Languages

PHP
23972 projects - #3 most used programming language
shell
77523 projects

Rollback Update Failure

Rollback Update Failure

  • Plugin Name: Rollback Update Failure
  • Contributors: afragen, aristath, costdev, pbiron
  • Tags: feature plugin, update, failure, auto-update
  • License: MIT
  • Requires PHP: 5.6
  • Requires at least: 5.2
  • Stable Tag: main

This is a feature plugin for testing automatic rollback of a plugin or theme update failure.

Description

This is a feature plugin for testing automatic rollback of a plugin or theme update failure.

It is based on the PR for #51857. Current PR #2225 for inclusion to core.

  • When updating a plugin/theme, the old version of the plugin/theme gets moved to a wp-content/upgrade/temp-backup/plugins/PLUGINNAME or wp-content/upgrade/temp-backup/themes/THEMENAME folder. The reason we chose to move instead of zip, is because zipping/unzipping are very resources-intensive processes, and would increase the risk on low-end, shared hosts. Moving on the other hand is performed instantly and won't be a bottleneck.
  • If the update fails, then the "backup" we kept in the upgrade/temp-backup folder gets restored to its original location
  • If the update succeeds, then the "backup" is deleted
  • 2 new checks were added in the site-health screen:
    • Check to make sure that the rollbacks folder is writable.
    • Check there is enough disk-space available to safely perform updates.

To avoid confusion: The "temp-backup" folder will NOT be used to "rollback" a plugin to a previous version after an update. This folder will simply contain a transient backup of the previous version of a plugins/themes getting updated, and as soon as the update process finishes, the folder will be empty.

This plugin will automatically deactivate itself once the feature has been committed to core.

There is a change to WP_Upgrader::install_package() that can't be implemented in the plugin. :sad:

If you are running a virtualized server and using VirtualBox we have a function that tries to identify VirtualBox with code. If you are running a VirtualBox environment the Site Health > Info > Server section will display whether the code picks that up correctly. If it doesn't you will need to add the following filter.

add_filter( 'is_virtualbox', '__return_true' );

Testing

  • If the wp-content/temp-backup folder is not writable, there should be an error in the site-health screen.
  • If the server has less than 20MB available, there should be an error in the site-health screen that updates may fail.
  • If the server has less than 100MB, it should be a notice that disk space is running low.
  • When updating a plugin, you should be able to see the old plugin in the wp-content/upgrade/temp-backup/plugins/PLUGINNAME folder. The same should apply for themes. Since updates sometimes run fast and we may miss the folder creation during testing, you can simulate an update failure to demonstrate. This will return early and skip deleting the backup on update-success.
  • When a plugin update fails, the previous version should be restored. To test that, change the version of a plugin to a previous number, run the update, and on fail the previous version (the one where you changed the version number) should still be installed on the site. To simulate an update failure and confirm this works, you can use the snippet below:
add_filter( 'upgrader_install_package_result', function() {
   return new WP_Error( 'simulated_error', 'Simulated Error' );
});

Alternatively you can install the Rollback Update Testing plugin, activating it as needed.

Reporting

Please submit issues and PRs to GitHub.

Logo from a meme generator. Original artwork by Allie Brosh.

Changelog

Please see the Github repository: CHANGELOG.md.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].