Commit 7f790dd8e00 for woocommerce
commit 7f790dd8e00c29872549528461884df4eb01a92d
Author: Lucio Giannotta <lucio.giannotta@a8c.com>
Date: Wed Apr 22 00:03:58 2026 +0800
Encapsulate product lookup table refresh behind a dedicated method (#64093)
Reverts the update_lookup_table() visibility change from protected to
public and adds a targeted refresh_product_lookup_table() method on
WC_Product_Data_Store_CPT instead. This hides the table name from
callers and keeps the internal update_lookup_table() protected and
refactorable.
diff --git a/plugins/woocommerce/changelog/fix-encapsulate-product-lookup-table-refresh b/plugins/woocommerce/changelog/fix-encapsulate-product-lookup-table-refresh
new file mode 100644
index 00000000000..936883bddfd
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-encapsulate-product-lookup-table-refresh
@@ -0,0 +1,4 @@
+Significance: patch
+Type: tweak
+
+Encapsulate product lookup table refresh behind a dedicated public method
diff --git a/plugins/woocommerce/includes/data-stores/class-wc-data-store-wp.php b/plugins/woocommerce/includes/data-stores/class-wc-data-store-wp.php
index 91e2181bf19..657d7c2c1d6 100644
--- a/plugins/woocommerce/includes/data-stores/class-wc-data-store-wp.php
+++ b/plugins/woocommerce/includes/data-stores/class-wc-data-store-wp.php
@@ -600,7 +600,7 @@ class WC_Data_Store_WP {
*
* @return NULL
*/
- public function update_lookup_table( $id, $table ) {
+ protected function update_lookup_table( $id, $table ) {
global $wpdb;
$id = absint( $id );
diff --git a/plugins/woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php b/plugins/woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php
index 2d7716d9341..9aac5fae00d 100644
--- a/plugins/woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php
+++ b/plugins/woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php
@@ -942,6 +942,17 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
$this->updated_props = array();
}
+ /**
+ * Refresh the product meta lookup table row for a given product.
+ *
+ * @since 10.8.0
+ * @param int $product_id Product ID.
+ * @return void
+ */
+ public function refresh_product_lookup_table( int $product_id ): void {
+ $this->update_lookup_table( $product_id, 'wc_product_meta_lookup' );
+ }
+
/**
* For all stored terms in all taxonomies, save them to the DB.
*
diff --git a/plugins/woocommerce/includes/wc-product-functions.php b/plugins/woocommerce/includes/wc-product-functions.php
index d626efd1f28..aeec1e846d7 100644
--- a/plugins/woocommerce/includes/wc-product-functions.php
+++ b/plugins/woocommerce/includes/wc-product-functions.php
@@ -647,7 +647,9 @@ function wc_apply_sale_state_for_product( WC_Product $product, string $mode ): v
// Refresh the lookup table since only the `price` prop changed, which is
// not in the tracked props list in handle_updated_props().
$data_store = WC_Data_Store::load( 'product' );
- $data_store->update_lookup_table( $product_id, 'wc_product_meta_lookup' ); // @phpstan-ignore method.notFound (Called via __call() on the underlying WC_Data_Store_WP instance.)
+ if ( $data_store->has_callable( 'refresh_product_lookup_table' ) ) {
+ $data_store->refresh_product_lookup_table( $product_id ); // @phpstan-ignore method.notFound (Guarded by has_callable() and called via __call() on the underlying product data store instance.)
+ }
wc_delete_product_transients( $product_id );