Skip to content

Commit

Permalink
Fixes notices being displayed on WordPress 6.7 due to loading transla…
Browse files Browse the repository at this point in the history
…tions too early. (#730)

* Remove unnecessary call to check if feature exists - fixes WP 6.7 compat

* Fix early translation calls in our privacy exporter/eraser class

* Register caching debug tools after init to fix translation issues

* Add changelog entry
  • Loading branch information
mattallan committed Nov 26, 2024
1 parent 07bf070 commit e2bd804
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
*** WooCommerce Subscriptions Core Changelog ***

= 7.7.2 - xxxx-xx-xx =
* Fix - Prevents notices being displayed on WordPress 6.7 due to loading translations too early.

= 7.7.1 - 2024-11-13 =
* Fix - Only show the individual subscription information in customer notification emails, not all subscriptions purchased in the initial order.
* Fix - Resolved issues with Customer Notification emails not being sent due to unsupported emoji used in the default email subject.
Expand Down
7 changes: 7 additions & 0 deletions includes/data-stores/class-wcs-customer-store-cached-cpt.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,20 @@ protected function init() {

$this->object_data_cache_manager->init();

add_action( 'init', array( $this, 'register_debug_tools' ) );

// When a user is first added, make sure the subscription cache is empty because it can not have any data yet, and we want to avoid running the query needlessly
add_filter( 'user_register', array( $this, 'set_empty_cache' ) );

// When the post for a subscription is change, make sure the corresponding cache is updated
add_action( 'wcs_update_post_meta_caches', array( $this, 'maybe_update_for_post_meta_change' ), 10, 5 );
add_action( 'wcs_delete_all_post_meta_caches', array( $this, 'maybe_delete_all_for_post_meta_change' ), 10, 1 );
}

/**
* Register debug tools for managing the cache.
*/
public function register_debug_tools() {
WCS_Debug_Tool_Factory::add_cache_tool( 'generator', __( 'Generate Customer Subscription Cache', 'woocommerce-subscriptions' ), __( 'This will generate the persistent cache for linking users with subscriptions. The caches will be generated overtime in the background (via Action Scheduler).', 'woocommerce-subscriptions' ), self::instance() );
WCS_Debug_Tool_Factory::add_cache_tool( 'eraser', __( 'Delete Customer Subscription Cache', 'woocommerce-subscriptions' ), __( 'This will clear the persistent cache of all of subscriptions stored against users in your store. Expect slower performance of checkout, renewal and other subscription related functions after taking this action. The caches will be regenerated overtime as queries to find a given user\'s subscriptions are run.', 'woocommerce-subscriptions' ), self::instance() );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ protected function init() {

$this->object_data_cache_manager->init();

add_action( 'init', array( $this, 'register_debug_tools' ) );

// When a subscription is being read from the database, don't load cached related order meta data into subscriptions.
add_filter( 'wcs_subscription_data_store_props_to_ignore', array( $this, 'add_related_order_cache_props' ), 10, 2 );

Expand All @@ -104,7 +106,12 @@ protected function init() {

// When copying meta from a subscription to a renewal order, don't copy cache related order meta keys.
add_filter( 'wc_subscriptions_renewal_order_data', array( $this, 'remove_related_order_cache_keys' ), 10, 1 );
}

/**
* Register debug tools for managing the cache.
*/
public function register_debug_tools() {
WCS_Debug_Tool_Factory::add_cache_tool( 'generator', __( 'Generate Related Order Cache', 'woocommerce-subscriptions' ), __( 'This will generate the persistent cache of all renewal, switch, resubscribe and other order types for all subscriptions in your store. The caches will be generated overtime in the background (via Action Scheduler).', 'woocommerce-subscriptions' ), self::instance() );
WCS_Debug_Tool_Factory::add_cache_tool( 'eraser', __( 'Delete Related Order Cache', 'woocommerce-subscriptions' ), __( 'This will clear the persistent cache of all renewal, switch, resubscribe and other order types for all subscriptions in your store. Expect slower performance of checkout, renewal and other subscription related functions after taking this action. The caches will be regenerated overtime as related order queries are run.', 'woocommerce-subscriptions' ), self::instance() );
}
Expand Down
11 changes: 10 additions & 1 deletion includes/privacy/class-wcs-privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ public function __construct() {
self::$background_process = new WCS_Privacy_Background_Updater();
}

parent::__construct( __( 'WooCommerce Subscriptions', 'woocommerce-subscriptions' ) );
parent::__construct();

add_action( 'init', array( $this, 'register_erasers_exporters' ) );
}

/**
* Register erasers and exporters.
*/
public function register_erasers_exporters() {
$this->name = __( 'WooCommerce Subscriptions', 'woocommerce-subscriptions' );

// Add our exporters and erasers.
$this->add_exporter( 'woocommerce-subscriptions-data', __( 'Subscriptions Data', 'woocommerce-subscriptions' ), array( 'WCS_Privacy_Exporters', 'subscription_data_exporter' ) );
Expand Down
6 changes: 1 addition & 5 deletions includes/wcs-compatibility-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -603,11 +603,7 @@ function wcs_is_wc_feature_enabled( $feature_name ) {
* @return bool
*/
function wcs_is_custom_order_tables_usage_enabled() {
if ( ! class_exists( '\Automattic\WooCommerce\Utilities\OrderUtil' ) || ! wcs_is_wc_feature_enabled( 'custom_order_tables' ) ) {
return false;
}

return \Automattic\WooCommerce\Utilities\OrderUtil::custom_orders_table_usage_is_enabled();
return class_exists( '\Automattic\WooCommerce\Utilities\OrderUtil' ) && \Automattic\WooCommerce\Utilities\OrderUtil::custom_orders_table_usage_is_enabled();
}

/**
Expand Down

0 comments on commit e2bd804

Please sign in to comment.