WordPress.org

Make WordPress Core

Changeset 52165


Ignore:
Timestamp:
11/15/2021 07:57:28 PM (2 months ago)
Author:
hellofromTonya
Message:

Upgrade/Install: Deactivate the Gutenberg plugin if its version is 11.8 or lower.

Avoid a fatal error due to WP_Theme_JSON_Schema and potentially other classes and/or functions redeclarations when updating to WordPress 5.9 with an incompatible version of the Gutenberg plugin.

This commit uses the same strategy from 5.8. Moves the plugin deactivation code (introduced in [51266]) to a private function for reuse in 5.8, 5.9, and future major releases.

Follow-up to [51180], [51266].

Props hellofromTonya, johnbillion, jorbin.
See #54405.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/update-core.php

    r52093 r52165  
    14021402    _upgrade_580_force_deactivate_incompatible_plugins();
    14031403
     1404    // Deactivate the Gutenberg plugin if its version is 11.8 or lower.
     1405    _upgrade_590_force_deactivate_incompatible_plugins();
     1406
    14041407    // Upgrade DB with separate request.
    14051408    /** This filter is documented in wp-admin/includes/update-core.php */
     
    16861689
    16871690/**
     1691 * @access private
    16881692 * @ignore
    16891693 * @since 5.8.0
     
    16911695function _upgrade_580_force_deactivate_incompatible_plugins() {
    16921696    if ( defined( 'GUTENBERG_VERSION' ) && version_compare( GUTENBERG_VERSION, '10.7', '<=' ) ) {
    1693         $deactivated_gutenberg['gutenberg'] = array(
    1694             'plugin_name'         => 'Gutenberg',
    1695             'version_deactivated' => GUTENBERG_VERSION,
    1696             'version_compatible'  => '10.8',
    1697         );
    1698         if ( is_plugin_active_for_network( 'gutenberg/gutenberg.php' ) ) {
    1699             $deactivated_plugins = get_site_option( 'wp_force_deactivated_plugins', array() );
    1700             $deactivated_plugins = array_merge( $deactivated_plugins, $deactivated_gutenberg );
    1701             update_site_option( 'wp_force_deactivated_plugins', $deactivated_plugins );
    1702         } else {
    1703             $deactivated_plugins = get_option( 'wp_force_deactivated_plugins', array() );
    1704             $deactivated_plugins = array_merge( $deactivated_plugins, $deactivated_gutenberg );
    1705             update_option( 'wp_force_deactivated_plugins', $deactivated_plugins );
    1706         }
    1707         deactivate_plugins( array( 'gutenberg/gutenberg.php' ), true );
     1697        _deactivate_gutenberg_when_incompatible_with_wp( '10.8' );
    17081698    }
    17091699}
     1700
     1701/**
     1702 * @access private
     1703 * @ignore
     1704 * @since 5.9.0
     1705 */
     1706function _upgrade_590_force_deactivate_incompatible_plugins() {
     1707    if ( defined( 'GUTENBERG_VERSION' ) && version_compare( GUTENBERG_VERSION, '11.8', '<=' ) ) {
     1708        _deactivate_gutenberg_when_incompatible_with_wp( '11.9' );
     1709    }
     1710}
     1711
     1712/**
     1713 * Deactivates the Gutenberg plugin when its version is incompatible.
     1714 *
     1715 * @access private
     1716 * @ignore
     1717 * @since 5.9.0
     1718 *
     1719 * @param string $compatible_version The version of Gutenberg plugin that is compatible.
     1720 */
     1721function _deactivate_gutenberg_when_incompatible_with_wp( $compatible_version ) {
     1722    $deactivated_gutenberg['gutenberg'] = array(
     1723        'plugin_name'         => 'Gutenberg',
     1724        'version_deactivated' => GUTENBERG_VERSION,
     1725        'version_compatible'  => $compatible_version,
     1726    );
     1727    if ( is_plugin_active_for_network( 'gutenberg/gutenberg.php' ) ) {
     1728        $deactivated_plugins = get_site_option( 'wp_force_deactivated_plugins', array() );
     1729        $deactivated_plugins = array_merge( $deactivated_plugins, $deactivated_gutenberg );
     1730        update_site_option( 'wp_force_deactivated_plugins', $deactivated_plugins );
     1731    } else {
     1732        $deactivated_plugins = get_option( 'wp_force_deactivated_plugins', array() );
     1733        $deactivated_plugins = array_merge( $deactivated_plugins, $deactivated_gutenberg );
     1734        update_option( 'wp_force_deactivated_plugins', $deactivated_plugins );
     1735    }
     1736    deactivate_plugins( array( 'gutenberg/gutenberg.php' ), true );
     1737}
Note: See TracChangeset for help on using the changeset viewer.