From c264ba80df1e400d5b1f19fe1a3fda96c7983a54 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 18 Jun 2021 12:12:57 +0000 Subject: [PATCH] Upgrade/Install: Deactivate the Gutenberg plugin if its version is 10.7 or lower. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids a fatal error due to `WP_Block_Template` class redeclaration when updating to WordPress 5.8 with an older version of Gutenberg activated. Follow-up to [35582] for the REST API plugin. Props hellofromTonya, oglekler, azaozz, desrosj, pbiron, jorbin, youknowriad, TimothyBlynJacobs, Clorith, markparnell. See #53432. git-svn-id: https://develop.svn.wordpress.org/trunk@51180 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/update-core.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/includes/update-core.php b/src/wp-admin/includes/update-core.php index 6e8e3e270a..32c70a19f0 100644 --- a/src/wp-admin/includes/update-core.php +++ b/src/wp-admin/includes/update-core.php @@ -1384,9 +1384,12 @@ function update_core( $from, $to ) { // Remove any Genericons example.html's from the filesystem. _upgrade_422_remove_genericons(); - // Remove the REST API plugin if its version is Beta 4 or lower. + // Deactivate the REST API plugin if its version is 2.0 Beta 4 or lower. _upgrade_440_force_deactivate_incompatible_plugins(); + // Deactivate the Gutenberg plugin if its version is 10.7 or lower. + _upgrade_580_force_deactivate_incompatible_plugins(); + // Upgrade DB with separate request. /** This filter is documented in wp-admin/includes/update-core.php */ apply_filters( 'update_feedback', __( 'Upgrading database…' ) ); @@ -1662,3 +1665,13 @@ function _upgrade_440_force_deactivate_incompatible_plugins() { deactivate_plugins( array( 'rest-api/plugin.php' ), true ); } } + +/** + * @ignore + * @since 5.8.0 + */ +function _upgrade_580_force_deactivate_incompatible_plugins() { + if ( defined( 'GUTENBERG_VERSION' ) && version_compare( GUTENBERG_VERSION, '10.7', '<=' ) ) { + deactivate_plugins( array( 'gutenberg/gutenberg.php' ), true ); + } +}