by WP Core Contributors.
This is a feature plugin for testing automatic rollback of a plugin or theme update failure.
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 and PR #3958 for inclusion to core.
wp-content/temp-backup/plugins/PLUGINNAME
or wp-content/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.temp-backup
folder gets restored to its original locationTo avoid confusion: The “temp-backup” folder will NOT be used to “roll-back” 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.
wp-content/temp-backup
folder is not writable, there should be an error in the site-health screen.wp-content/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.
Or use the built-in simulate failure feature. Just activate/deactivate from the plugins.php
page action link.
Please submit issues and PRs to GitHub.
Logo from a meme generator. Original artwork by Allie Brosh.
Please see the Github repository: CHANGELOG.md.
move_dir()
called with 3rd parameter as move_dir($from, $to, true)
WP_Rollback_Auto_Update::restart_updates
remove shutdown hook for WP_Upgrader::delete_temp_backup
create_backup
move_dir()
for new parametermove_dir()
possibly returning WP_Error
sprintf
errorupgrade_plugins
transient to object, overkill but someone reported an errormove_dir()
, auto-install/activateWP_Upgrader::install_package
update-core.php
array_unique
when saving simulated failure optionsinit
hook for WP-CLIwp-content/temp-backup
and not wp-content/upgrade/temp-backup
as WP_Upgrader::unpack_package
deletes contents of wp-content-upgrade
at each updateupgrader_source_selection
from upgrader_pre_install
to resolve an edge casepre_move_dir
and post_move_dir
hooksdelete_temp_backup()
wp_delete_temp_updater_backups
cron task, oopsshutdown
hook in wp_delete_all_temp_backups()
for plugin namespace, not for PRwp_delete_temp_updater_backups
for plugin namespace, not for PRcopy_dir( $skip_list )
to avoid potential endless looping.$options
for callback functionsis_virtualbox()
for testingmove_dir()
move_dir()
is_virtualbox()
WP_RUNTIME_ENVIRONMENT
and wp_get_runtime_environment()
restore_temp_backup()
in shutdown
hookwp_get_runtime_environment()
to return value of constant WP_RUNTIME_ENVIRONMENT
(int)
casting for disk_free_space()
is_virtual_box()
to get whether running in VirtualBox, requires define( 'ENV_VB', true )
or genenv( 'WP_ENV_VB' )
evaluating to truerename()
as VirtualBox gets borked when using rename()
move_dir()
instead of $wp_filesystem->move()
disk_free_space()
5.9-beta1
disk_free_space()
and degrade gracefully$hook_extra
is emptyextract_rollback
upgrader_install_package_result
filter and parameters passedrollback_update_testing
to simulate a failure.