Merge pull request #29200 from woocommerce/fix/upgrade-notices-major-version

Remove compatibility checks for major version
This commit is contained in:
Vedanshu Jain 2021-02-26 14:55:30 +05:30 committed by GitHub
commit 422002a2a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 9 deletions

View File

@ -6,6 +6,8 @@
* @version 3.2.0
*/
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
@ -37,8 +39,13 @@ class WC_Updates_Screen_Updates extends WC_Plugin_Updates {
return;
}
$version_type = Constants::get_constant( 'WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE' );
if ( ! is_string( $version_type ) ) {
$version_type = 'none';
}
$this->new_version = wc_clean( $updateable_plugins['woocommerce/woocommerce.php']->update->new_version );
$this->major_untested_plugins = $this->get_untested_plugins( $this->new_version, 'major' );
$this->major_untested_plugins = $this->get_untested_plugins( $this->new_version, $version_type );
if ( ! empty( $this->major_untested_plugins ) ) {
echo $this->get_extensions_modal_warning(); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped

View File

@ -5,16 +5,12 @@
* @package WooCommerce
*/
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit;
global $wpdb;
if ( ! defined( 'WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE' ) ) {
// Define if we're checking against major or minor versions.
// Since 5.0 all versions are backwards compatible, so there's no more check.
define( 'WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE', 'none' );
}
$report = wc()->api->get_endpoint_data( '/wc/v3/system_status' );
$environment = $report['environment'];
$database = $report['database'];
@ -27,7 +23,7 @@ $security = $report['security'];
$settings = $report['settings'];
$wp_pages = $report['pages'];
$plugin_updates = new WC_Plugin_Updates();
$untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE );
$untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, Constants::get_constant( 'WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE' ) );
?>
<div class="updated woocommerce-message inline">
<p>

View File

@ -249,6 +249,18 @@ final class WooCommerce {
$this->define( 'WC_NOTICE_MIN_PHP_VERSION', '7.2' );
$this->define( 'WC_NOTICE_MIN_WP_VERSION', '5.2' );
$this->define( 'WC_PHP_MIN_REQUIREMENTS_NOTICE', 'wp_php_min_requirements_' . WC_NOTICE_MIN_PHP_VERSION . '_' . WC_NOTICE_MIN_WP_VERSION );
/** Define if we're checking against major, minor or no versions in the following places:
* - plugin screen in WP Admin (displaying extra warning when updating to new major versions)
* - System Status Report ('Installed version not tested with active version of WooCommerce' warning)
* - core update screen in WP Admin (displaying extra warning when updating to new major versions)
* - enable/disable automated updates in the plugin screen in WP Admin (if there are any plugins
* that don't declare compatibility, the auto-update is disabled)
*
* We dropped SemVer before WC 5.0, so all versions are backwards compatible now, thus no more check needed.
* The SSR in the name is preserved for bw compatibility, as this was initially used in System Status Report.
*/
$this->define( 'WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE', 'none' );
}
/**

View File

@ -2255,7 +2255,11 @@ function wc_prevent_dangerous_auto_updates( $should_update, $plugin ) {
$new_version = wc_clean( $plugin->new_version );
$plugin_updates = new WC_Plugin_Updates();
$untested_plugins = $plugin_updates->get_untested_plugins( $new_version, 'major' );
$version_type = Constants::get_constant( 'WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE' );
if ( ! is_string( $version_type ) ) {
$version_type = 'none';
}
$untested_plugins = $plugin_updates->get_untested_plugins( $new_version, $version_type );
if ( ! empty( $untested_plugins ) ) {
return false;
}