From 694fb67980b10e21878db2e56f3d8efc6bba355e Mon Sep 17 00:00:00 2001 From: Vedanshu Jain Date: Thu, 26 Jan 2023 11:51:28 +0530 Subject: [PATCH] Temporary disable cache before backfilling. --- .../DataStores/Orders/DataSynchronizer.php | 23 +++++++++++++------ .../OrdersDataStoreServiceProvider.php | 1 + 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/plugins/woocommerce/src/Internal/DataStores/Orders/DataSynchronizer.php b/plugins/woocommerce/src/Internal/DataStores/Orders/DataSynchronizer.php index 8ac740bd207..8ed2f9946f9 100644 --- a/plugins/woocommerce/src/Internal/DataStores/Orders/DataSynchronizer.php +++ b/plugins/woocommerce/src/Internal/DataStores/Orders/DataSynchronizer.php @@ -65,6 +65,13 @@ class DataSynchronizer implements BatchProcessorInterface { */ private $error_logger; + /** + * The order cache controller. + * + * @var OrderCacheController + */ + private $order_cache_controller; + /** * Class constructor. */ @@ -88,12 +95,14 @@ class DataSynchronizer implements BatchProcessorInterface { OrdersTableDataStore $data_store, DatabaseUtil $database_util, PostsToOrdersMigrationController $posts_to_cot_migrator, - LegacyProxy $legacy_proxy + LegacyProxy $legacy_proxy, + OrderCacheController $order_cache_controller ) { - $this->data_store = $data_store; - $this->database_util = $database_util; - $this->posts_to_cot_migrator = $posts_to_cot_migrator; - $this->error_logger = $legacy_proxy->call_function( 'wc_get_logger' ); + $this->data_store = $data_store; + $this->database_util = $database_util; + $this->posts_to_cot_migrator = $posts_to_cot_migrator; + $this->error_logger = $legacy_proxy->call_function( 'wc_get_logger' ); + $this->order_cache_controller = $order_cache_controller; } /** @@ -336,7 +345,7 @@ WHERE * @param array $batch Batch details. */ public function process_batch( array $batch ) : void { - $this->cache_controller->temporarily_disable_orders_cache_usage(); + $this->order_cache_controller->temporarily_disable_orders_cache_usage(); if ( $this->custom_orders_table_is_authoritative() ) { foreach ( $batch as $id ) { @@ -353,7 +362,7 @@ WHERE } if ( 0 === $this->get_total_pending_count() ) { $this->cleanup_synchronization_state(); - $this->cache_controller->maybe_restore_orders_cache_usage(); + $this->order_cache_controller->maybe_restore_orders_cache_usage(); } } diff --git a/plugins/woocommerce/src/Internal/DependencyManagement/ServiceProviders/OrdersDataStoreServiceProvider.php b/plugins/woocommerce/src/Internal/DependencyManagement/ServiceProviders/OrdersDataStoreServiceProvider.php index 787ff605ead..6759df08426 100644 --- a/plugins/woocommerce/src/Internal/DependencyManagement/ServiceProviders/OrdersDataStoreServiceProvider.php +++ b/plugins/woocommerce/src/Internal/DependencyManagement/ServiceProviders/OrdersDataStoreServiceProvider.php @@ -56,6 +56,7 @@ class OrdersDataStoreServiceProvider extends AbstractServiceProvider { DatabaseUtil::class, PostsToOrdersMigrationController::class, LegacyProxy::class, + OrderCacheController::class, ) ); $this->share( OrdersTableRefundDataStore::class )->addArguments( array( OrdersTableDataStoreMeta::class, DatabaseUtil::class, LegacyProxy::class ) );