From abc3b6ca470ed16c6fe8ae502545e4eef831c375 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 5 Mar 2019 16:16:46 +0000 Subject: [PATCH] Use cache helper for invalidation --- includes/wc-attribute-functions.php | 8 ++++++-- includes/wc-update-functions.php | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/includes/wc-attribute-functions.php b/includes/wc-attribute-functions.php index 7a19bc59462..ab4b0a1c661 100644 --- a/includes/wc-attribute-functions.php +++ b/includes/wc-attribute-functions.php @@ -67,7 +67,8 @@ function wc_get_attribute_taxonomies() { * @return array */ function wc_get_attribute_taxonomy_ids() { - $cache_key = 'attribute-ids'; + $prefix = WC_Cache_Helper::get_cache_prefix( 'woocommerce-attributes' ); + $cache_key = $prefix . 'attribute-ids'; $cache_value = wp_cache_get( $cache_key, 'woocommerce-attributes' ); if ( $cache_value ) { @@ -579,6 +580,7 @@ function wc_create_attribute( $args ) { // Clear cache and flush rewrite rules. wp_schedule_single_event( time(), 'woocommerce_flush_rewrite_rules' ); delete_transient( 'wc_attribute_taxonomies' ); + WC_Cache_Helper::incr_cache_prefix( 'woocommerce-attributes' ); return $id; } @@ -668,6 +670,7 @@ function wc_delete_attribute( $id ) { do_action( 'woocommerce_attribute_deleted', $id, $name, $taxonomy ); wp_schedule_single_event( time(), 'woocommerce_flush_rewrite_rules' ); delete_transient( 'wc_attribute_taxonomies' ); + WC_Cache_Helper::incr_cache_prefix( 'woocommerce-attributes' ); return true; } @@ -684,7 +687,8 @@ function wc_delete_attribute( $id ) { * @return string */ function wc_attribute_taxonomy_slug( $attribute_name ) { - $cache_key = 'slug-' . $attribute_name; + $prefix = WC_Cache_Helper::get_cache_prefix( 'woocommerce-attributes' ); + $cache_key = $prefix . 'slug-' . $attribute_name; $cache_value = wp_cache_get( $cache_key, 'woocommerce-attributes' ); if ( $cache_value ) { diff --git a/includes/wc-update-functions.php b/includes/wc-update-functions.php index affe3f71a27..fb7093d3db5 100644 --- a/includes/wc-update-functions.php +++ b/includes/wc-update-functions.php @@ -672,6 +672,9 @@ function wc_update_220_attributes() { } } } + + delete_transient( 'wc_attribute_taxonomies' ); + WC_Cache_Helper::incr_cache_prefix( 'woocommerce-attributes' ); } /**