Skip to content

Commit

Permalink
Deprecate upgrade scripts for versions before version 3 (#163)
Browse files Browse the repository at this point in the history
* Deprecate upgrad scripts for versions before subscriptions version 3

* fix missing deprecation

* Add changelog entry

* Replace x.x.x with correct deprecated versions

* Show notice based on the DB subscriptions version not the installed version

* Update changelog entry

* Move all deprecated functions to the bottom of the file

* Move all deprecated variables into a group

* Fix whitespace

---------

Co-authored-by: mattallan <[email protected]>
Co-authored-by: Wesley Rosa <[email protected]>
  • Loading branch information
3 people authored Nov 13, 2024
1 parent b7228b5 commit 43a02e7
Show file tree
Hide file tree
Showing 18 changed files with 308 additions and 297 deletions.
3 changes: 3 additions & 0 deletions assets/js/wcs-upgrade.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @deprecated subscriptions-core 7.7.0 This file is no longer in use and can be removed in future.
*/
jQuery( function ( $ ) {
var upgrade_start_time = null,
total_subscriptions = wcs_update_script_data.subscription_count;
Expand Down
3 changes: 2 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
*** WooCommerce Subscriptions Core Changelog ***

= 7.7.0 - xxxx-xx-xx =
* Dev - Update `get_post_meta()` calls to fetch product meta using CRUD getters.
* Fix - Prevent adding products to the cart if a subscription renewal is already present.
* Update - Improved performance of wcs_get_subscription() when querying by product and customer or order.
* Update - Improved performance when checking limited subscription product availability.
* Update - Deprecate upgrading from versions of WooCommerce Subscriptions prior to 3.0.0 (released Jan 2020).
* Dev - Minor refactoring of `init` method in `WC_Subscriptions_Upgrader` class.
* Dev - Introduce the filter `woocommerce_subscriptions_synced_first_renewal_payment_timestamp` to enable plugins to modify the first renewal date of synced subscriptions.
* Dev - Update `get_post_meta()` calls to fetch product meta using CRUD getters.

= 7.6.0 - 2024-10-14 =
* Fix - Correctly updates a subscription status to `cancelled` during a payment failure call when the current status is `pending-cancel`.
Expand Down
546 changes: 254 additions & 292 deletions includes/upgrades/class-wc-subscriptions-upgrader.php

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions includes/upgrades/class-wcs-repair-2-0-2.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
exit; // Exit if accessed directly
}

/**
* @deprecated
*/
class WCS_Repair_2_0_2 {

/**
Expand Down
3 changes: 3 additions & 0 deletions includes/upgrades/class-wcs-repair-2-0.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
exit; // Exit if accessed directly
}

/**
* @deprecated
*/
class WCS_Repair_2_0 {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
exit;
}

/**
* @deprecated
*/
class WCS_Repair_Line_Item_Has_Trial_Meta extends WCS_Background_Repairer {

/**
Expand Down
3 changes: 3 additions & 0 deletions includes/upgrades/class-wcs-repair-start-date-metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
exit;
}

/**
* @deprecated
*/
class WCS_Repair_Start_Date_Metadata extends WCS_Background_Upgrader {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
exit;
}

/**
* @deprecated
*/
class WCS_Repair_Subscription_Address_Indexes extends WCS_Background_Upgrader {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
exit;
}

/**
* @deprecated
*/
class WCS_Repair_Suspended_PayPal_Subscriptions extends WCS_Background_Upgrader {

/**
Expand Down
4 changes: 4 additions & 0 deletions includes/upgrades/class-wcs-upgrade-1-2.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@
exit; // Exit if accessed directly
}

/**
* @deprecated subscriptions-core 7.7.0
*/
class WCS_Upgrade_1_2 {

public static function init() {
global $wpdb;
wcs_deprecated_function( __METHOD__, 'subscriptions-core 7.7.0' );

// Get IDs only and use a direct DB query for efficiency
$orders_to_upgrade = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type = 'shop_order' AND post_parent = 0" );
Expand Down
5 changes: 4 additions & 1 deletion includes/upgrades/class-wcs-upgrade-1-3.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}

/**
* @deprecated subscription-core 7.7.0
*/
class WCS_Upgrade_1_3 {

public static function init() {
wcs_deprecated_function( __METHOD__, 'subscriptions-core 7.7.0' );
global $wpdb;

// Change transient timeout entries to be a vanilla option
Expand Down
9 changes: 6 additions & 3 deletions includes/upgrades/class-wcs-upgrade-1-4.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
exit; // Exit if accessed directly
}

/**
* @deprecated subscriptions-core 7.7.0
*/
class WCS_Upgrade_1_4 {

private static $last_upgraded_user_id = false;

public static function init() {

wcs_deprecated_function( __METHOD__, 'subscriptions-core 7.7.0' );
global $wpdb;

$subscriptions_meta_key = $wpdb->get_blog_prefix() . 'woocommerce_subscriptions';
Expand Down Expand Up @@ -166,11 +169,11 @@ public static function init() {
*
* Needs to be a separate function so that it can use a static variable (and therefore avoid calling get_option() thousands
* of times when iterating over thousands of users).
*
* @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
* @deprecated subscriptions-core 7.7.0
*/
public static function is_user_upgraded( $user_id ) {

wcs_deprecated_function( __METHOD__, 'subscriptions-core 7.7.0' );
if ( false === self::$last_upgraded_user_id ) {
self::$last_upgraded_user_id = get_option( 'wcs_1_4_last_upgraded_user_id', 0 );
}
Expand Down
2 changes: 2 additions & 0 deletions includes/upgrades/class-wcs-upgrade-1-5.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class WCS_Upgrade_1_5 {
* Subscriptions 1.5 made it possible for a product to be sold individually or in multiple quantities, whereas
* previously it was possible only to buy a subscription product in a single quantity.
*
* @deprecated
* @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function upgrade_products() {
Expand Down Expand Up @@ -54,6 +55,7 @@ public static function upgrade_products() {
/**
* Update subscription WP-Cron tasks to Action Scheduler.
*
* @deprecated
* @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function upgrade_hooks( $number_hooks_to_upgrade ) {
Expand Down
3 changes: 3 additions & 0 deletions includes/upgrades/class-wcs-upgrade-2-0.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
exit; // Exit if accessed directly
}

/**
* @deprecated
*/
class WCS_Upgrade_2_0 {

/* Cache of order item meta keys that were used to store subscription data in v1.5 */
Expand Down
3 changes: 3 additions & 0 deletions includes/upgrades/class-wcs-upgrade-2-1.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
exit; // Exit if accessed directly
}

/**
* @deprecated
*/
class WCS_Upgrade_2_1 {

/**
Expand Down
3 changes: 3 additions & 0 deletions includes/upgrades/class-wcs-upgrade-2-2-7.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
exit; // Exit if accessed directly
}

/**
* @deprecated
*/
class WCS_Upgrade_2_2_7 {

private static $cron_hook = 'wcs_repair_end_of_prepaid_term_actions';
Expand Down
3 changes: 3 additions & 0 deletions includes/upgrades/class-wcs-upgrade-2-2-9.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
exit; // Exit if accessed directly
}

/**
* @deprecated
*/
class WCS_Upgrade_2_2_9 {

private static $cron_hook = 'wcs_repair_subscriptions_containing_synced_variations';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
exit; // Exit if accessed directly
}

/**
* @deprecated
*/
class WCS_Upgrade_Subscription_Post_Author extends WCS_Background_Upgrader {

/**
Expand Down

0 comments on commit 43a02e7

Please sign in to comment.