Move clear cache to after backfilling bit is set as its not atomic.

This commit is contained in:
Vedanshu Jain 2023-09-21 13:22:17 +05:30
parent c6afc7a4c3
commit 4f425aca34
2 changed files with 11 additions and 3 deletions

View File

@ -2523,8 +2523,8 @@ FROM $order_meta_table
$order->save_meta_data();
if ( $backfill ) {
$this->clear_caches( $order );
self::$backfilling_order_ids[] = $order->get_id();
$this->clear_caches( $order );
$r_order = wc_get_order( $order->get_id() ); // Refresh order to account for DB changes from post hooks.
$this->maybe_backfill_post_record( $r_order );
self::$backfilling_order_ids = array_diff( self::$backfilling_order_ids, array( $order->get_id() ) );

View File

@ -3017,12 +3017,20 @@ class OrdersTableDataStoreTests extends HposTestCase {
wc_get_order( $order_id );
} );
$order = OrderHelper::create_order();
remove_all_actions( 'woocommerce_delete_shop_order_transients' );
$this->assertEquals( 1, $order->get_customer_id() );
$r_order = wc_get_order( $order->get_id() );
$this->assertEquals( 1, $r_order->get_customer_id() );
$this->reset_order_data_store_state( wc_get_container()->get( OrdersTableDataStore::class ) );
$order->set_customer_id( 2 );
$order->save();
$r_order = wc_get_order( $order->get_id() );
$this->assertEquals( 2, $r_order->get_customer_id() );
remove_all_actions( 'woocommerce_delete_shop_order_transients' );
}
/**