[wp-trac] [WordPress Trac] #51857: Add rollback for failed plugin/theme updates
WordPress Trac
noreply at wordpress.org
Thu Oct 21 10:18:54 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-testing-info needs-unit- | Focuses:
tests needs-testing needs-patch |
-------------------------------------------------+-------------------------
Changes (by johnbillion):
* keywords: early has-testing-info needs-unit-tests has-patch needs-
testing => early has-testing-info needs-unit-tests needs-testing
needs-patch
Comment:
There are some problems with the `delete_temp_updater_backups` cron event
added in [51815]. It's getting scheduled multiple times and its action is
not present when the event runs.
Ref: https://github.com/WordPress/wordpress-
develop/blob/ad9de4547cdba36567eb609e716dcd4aac4e3e38/src/wp-
admin/includes/class-wp-upgrader.php#L153-L154
* Inside `schedule_temp_backup_cleanup()` we have a call to
`wp_schedule_event()` which schedules the `delete_temp_updater_backups`
event, and a call to `add_action()` for this event. The problem is the
`schedule_temp_backup_cleanup()` method is only called when an upgrader
class is initialised with `init()` which only happens when an actual
upgrade process runs. This means the `delete_temp_updater_backups` event
does not have an action associated with it when the cron event runs. The
`add_action()` needs to move into `default-filters.php`.
* Each time an upgrader class is initialised by calling its `init()`
method it will schedule an additional weekly event for the
`delete_temp_updater_backups` hook. This can be seen by performing a few
updates, such as for plugins, themes, or translations, and then using a
cron management tool such as WP Crontrol or `wp cron event list` in WP-CLI
to inspect the list of cron events. An extra weekly event for
`delete_temp_updater_backups` will be scheduled each time. The
`schedule_temp_backup_cleanup()` method needs to only schedule this event
if one doesn't already exist.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51857#comment:155>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list