Make WordPress Core

Changeset 52199


Ignore:
Timestamp:
11/17/2021 05:43:41 PM (3 years ago)
Author:
hellofromTonya
Message:

Upgrade/Install: Remove 5.8 function and fix deactivate Gutenberg plugin version compare < 11.9.

Follow-up to [52165] where the version_compare() fails for 11.8.x versions. This commit changes the version comparison to < 11.9 for deactivating the Gutenberg plugin.

The _upgrade_580_force_deactivate_incompatible_plugins() function is no longer needed in 5.9. It's redundant and unnecessary as _upgrade_590_force_deactivate_incompatible_plugins() deactivates those versions as well.

Removing _upgrade_580_force_deactivate_incompatible_plugins() and moving the deactivation logic back into the _deactivate_gutenberg_when_incompatible_with_wp(), thus removing the new private function _deactivate_gutenberg_when_incompatible_with_wp() introduced in [52165].

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

Props hellofromTonya, tobiasbg, clorith, sergeybiryukov, costdev.
Fixes #54405.

File:
1 edited

Legend:

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

    r52165 r52199  
    13991399    _upgrade_440_force_deactivate_incompatible_plugins();
    14001400
    1401     // Deactivate the Gutenberg plugin if its version is 10.7 or lower.
    1402     _upgrade_580_force_deactivate_incompatible_plugins();
    1403 
    14041401    // Deactivate the Gutenberg plugin if its version is 11.8 or lower.
    14051402    _upgrade_590_force_deactivate_incompatible_plugins();
     
    16911688 * @access private
    16921689 * @ignore
    1693  * @since 5.8.0
    1694  */
    1695 function _upgrade_580_force_deactivate_incompatible_plugins() {
    1696     if ( defined( 'GUTENBERG_VERSION' ) && version_compare( GUTENBERG_VERSION, '10.7', '<=' ) ) {
    1697         _deactivate_gutenberg_when_incompatible_with_wp( '10.8' );
    1698     }
    1699 }
    1700 
    1701 /**
    1702  * @access private
    1703  * @ignore
    17041690 * @since 5.9.0
    17051691 */
    17061692function _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' );
     1693    if ( defined( 'GUTENBERG_VERSION' ) && version_compare( GUTENBERG_VERSION, '11.9', '<' ) ) {
     1694        $deactivated_gutenberg['gutenberg'] = array(
     1695            'plugin_name'         => 'Gutenberg',
     1696            'version_deactivated' => GUTENBERG_VERSION,
     1697            'version_compatible'  => '11.9',
     1698        );
     1699        if ( is_plugin_active_for_network( 'gutenberg/gutenberg.php' ) ) {
     1700            $deactivated_plugins = get_site_option( 'wp_force_deactivated_plugins', array() );
     1701            $deactivated_plugins = array_merge( $deactivated_plugins, $deactivated_gutenberg );
     1702            update_site_option( 'wp_force_deactivated_plugins', $deactivated_plugins );
     1703        } else {
     1704            $deactivated_plugins = get_option( 'wp_force_deactivated_plugins', array() );
     1705            $deactivated_plugins = array_merge( $deactivated_plugins, $deactivated_gutenberg );
     1706            update_option( 'wp_force_deactivated_plugins', $deactivated_plugins );
     1707        }
     1708        deactivate_plugins( array( 'gutenberg/gutenberg.php' ), true );
    17091709    }
    17101710}
    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  */
    1721 function _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.