{"id":112577,"date":"2024-04-19T17:21:37","date_gmt":"2024-04-19T17:21:37","guid":{"rendered":"https:\/\/make.wordpress.org\/core\/?p=112577"},"modified":"2024-04-20T18:30:59","modified_gmt":"2024-04-20T18:30:59","slug":"merge-proposal-rollback-auto-update","status":"publish","type":"post","link":"https:\/\/make.wordpress.org\/core\/2024\/04\/19\/merge-proposal-rollback-auto-update\/","title":{"rendered":"Merge Proposal: Rollback Auto-Update"},"content":{"rendered":"
The biggest risk for a site owner when updating plugins is encountering a PHPPHP<\/span> The web scripting language in which WordPress is primarily architected. WordPress requires PHP 7.4 or higher<\/span><\/span><\/span> fatal error that crashes their website. While CoreCore<\/span> Core is the set of software required to run WordPress. The Core Development Team builds WordPress.<\/span><\/span><\/span> updates are protected by automatic rollbacks since WordPress 3.7 (#22704<\/a>), no such protection for plugins was added. Although fatal error protection and recovery mode were added in WordPress 5.2, it requires manual intervention from an administrator, and ideally WordPress should be able to recover on its own in a similar way that Core does. The Upgrade\/Install team began exploring rollbacks for pluginPlugin<\/span> A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https:\/\/wordpress.org\/plugins\/ or can be cost-based plugin from a third-party<\/span><\/span><\/span> updates.<\/p>\n\n\n\n Rollbacks for plugin updates comprises three features:<\/p>\n\n\n\n When active plugins are updated, they are briefly deactivated before the new version is installed and reactivated immediately after. Since WordPress 6.3, when an administrator is manually updating plugins, the plugin will not be reactivated if the update causes a PHP fatal error. During an auto-update, this reactivation check does not occur and the next time the site runs users will see the white screen of death (WSOD).<\/p>\n\n\n\n To further protect websites and increase confidence in automatic plugin updates within WordPress, the Rollback Auto-Update feature pluginFeature Plugin<\/span> A plugin that was created with the intention of eventually being proposed for inclusion in WordPress Core. See Features as Plugins<\/a>.<\/span><\/span><\/span> aims to detect PHP fatal errors during automatic plugin updates, and subsequently rolls back to the previously installed version.<\/p>\n\n\n\n This proposal is to merge the changes required to also perform rollbacks when fatal errors occur during attempted plugin auto-updates by default.<\/p>\n\n\n\n Rollback Auto-Update performs a loopback request to the homepage to check for PHP fatal errors, using an approach similar to the Plugin or Theme File Editors<\/a>. If a PHP fatal error is encountered, an error handler logs the specific message and the previously installed version of the plugin is restored. When a plugin rollback occurs, a notification will be sent to the site\u2019s administration email (stored in the The current implementation attempts to detect a PHP fatal error during an automatic update by using a loopback request to the homepage. If the loopback returns an error, a PHP fatal error in the active plugin is assumed and the update will be reverted for safety.<\/p>\n\n\n\n After the problematic plugin is rolled back, the auto-updating process will continue for any other core, plugin, or theme updates that were in queue. When the next check for auto-updates occurs, WordPress will attempt to update the same plugin again.<\/p>\n\n\n\n Previously, maintenance mode was only enabled during installation of an update. However, testing established that disabling maintenance mode during the rest of the process means that active visits to the site can trigger errors. This can have side effects, such as deactivating plugins, etc. Rollback Auto-Update enables maintenance mode for the duration of all automatic updates. While maintenance mode is enabled for longer, this is relative to the number of updates being performed at that given time \u2013 usually a very low number \u2013 and helps improve stability of automatic updates.<\/p>\n\n\n\n At the time of publishing, this code is being tested on 6,000+ sites running the Rollback Update Failure feature plugin, which has contained the related code since v7.0.0 was released on 10\/12\/2023.<\/p>\n\n\n\n For easier testing of the feature within Due to limitations in the ability to modify Example of email text sent to site\u2019s administration email.<\/p>\n\n\n\n Howdy! Plugins failed to update on your site at https:\/\/test.xxxxx.net.<\/p>\n\n Please check your site now. It\u2019s possible that everything is working. If there are updates available, you should update.<\/p>\n\n The following plugins failed to update. If there was a fatal error in the update, the previously installed version has been restored. To manage plugins on your site, visit the Plugins page: https:\/\/test.xxxxx.net\/wp-admin\/plugins.php<\/p>\n\n If you experience any issues or need support, the volunteers in the WordPress.orgWordPress.org<\/span> The community site where WordPress code is created and shared by the users. This is where you can download the source code for WordPress core, plugins and themes as well as the central location for community conversations and organization. https:\/\/wordpress.org\/<\/a><\/span><\/span><\/span> support forums may be able to help. The WordPress Team<\/p>\n<\/div>\n\n\n\n There are no known issues directly related to Rollback Auto-Update that don\u2019t currently exist in Core.<\/p>\n\n\n\n I (@<\/span>afragen<\/a>) have been testing using the test plugin<\/a>. The plugin is on a test site, active, and set to auto-update. I have been running like this since the beginning of the year using the PR and on other sites for several years using the feature plugin.<\/p>\n\n\n\n The WordPress.org update APIAPI<\/span> An API or Application Programming Interface is a software intermediary that allows programs to interact with each other and share data in limited, clearly defined ways.<\/span><\/span><\/span> will serve the version 0.2 version of the plugin, which will cause a PHP fatal error. To confirm a rollback is successful, data is written to the Stay up to date with development on the PR. Please comment on the GitHub PR <\/a>if any problems are discovered.\u00a0<\/p>\n\n\n\n As a project, it\u2019s important to continuously evaluate ways to make site management easier for the large majority of users and site owners. Providing safer plugin auto-updates is just one way for WordPress itself to handle problems that may require technical expertise seamlessly for end users.<\/p>\n\n\n\n All feedback will be collected and addressed over the next 2-3 weeks, with the goal of committing to Props: @<\/span>costdev<\/a><\/em> and @<\/span>desrosj<\/a><\/em> for review and editing.<\/p>\n\n
Some background references<\/strong><\/h3>\n\n\n\n
\n
Overview<\/strong><\/h2>\n\n\n\n
Implementation<\/strong><\/h2>\n\n\n\n
admin_email<\/code> option) notifying them of the failed update and rollback.<\/p>\n\n\n\n
wordpress-develop<\/code>, a merge PR (Core-5287<\/a>) has been created.<\/p>\n\n\n\n
wp_is_maintenance_mode()<\/code> in the feature plugin, the PR is slightly different. The feature plugin is available for historical reference. All pre-merge testing should be done using the PR. Some contributors have also been running the PR on sites for a few months.<\/p>\n\n\n\n
\n<\/p>\n
\nhttps:\/\/wordpress.org\/support\/forums\/<\/p>\n\nTesting<\/strong><\/h2>\n\n\n\n
\n
error.log<\/code> at every point in the auto-update process, creating an audit trail the user can use to discern the flow and results of rolling back an auto-update. This logging is only intended for testing purposes.<\/p>\n\n\n\n
FAQ<\/strong><\/h2>\n\n\n\n
\n
\n
trunk<\/code> after all feedback is addressed to ensure that the feature gets plenty of testing through the nightly builds early in the WordPress 6.6<\/a> release cycle.<\/p>\n\n\n\n