Use 30 days instead of year for transients to avoid bugs in memcache plugins.

Closes #7520
This commit is contained in:
Mike Jolley 2015-02-24 12:02:56 +00:00
parent 492c8e361b
commit d9455994c8
9 changed files with 15 additions and 14 deletions

View File

@ -1050,7 +1050,7 @@ class WC_Product {
$average_rating = number_format( $ratings / $count, 2 );
}
set_transient( $transient_name, $average_rating, YEAR_IN_SECONDS );
set_transient( $transient_name, $average_rating, DAY_IN_SECONDS * 30 );
}
return $average_rating;
@ -1082,7 +1082,7 @@ class WC_Product {
AND comment_approved = '1'
", $this->id ) . $where_meta_value );
set_transient( $transient_name, $count, YEAR_IN_SECONDS );
set_transient( $transient_name, $count, DAY_IN_SECONDS * 30 );
}
return $count;
@ -1136,7 +1136,7 @@ class WC_Product {
AND comment_approved = '1'
", $this->id ) );
set_transient( $transient_name, $count, YEAR_IN_SECONDS );
set_transient( $transient_name, $count, DAY_IN_SECONDS * 30 );
}
return apply_filters( 'woocommerce_product_review_count', $count, $this );
@ -1309,7 +1309,7 @@ class WC_Product {
$max_related_posts_query = $query;
$max_related_posts_query['fields'] = "SELECT COUNT(DISTINCT ID) FROM {$wpdb->posts} p";
$max_related_posts = absint( $wpdb->get_var( implode( ' ', apply_filters( 'woocommerce_product_max_related_posts_query', $max_related_posts_query, $this->id ) ) ) );
set_transient( $max_related_posts_transient_name, $max_related_posts, YEAR_IN_SECONDS );
set_transient( $max_related_posts_transient_name, $max_related_posts, DAY_IN_SECONDS * 30 );
}
// Generate limit

View File

@ -71,7 +71,7 @@ class WC_Product_Grouped extends WC_Product {
}
}
set_transient( $transient_name, $this->total_stock, YEAR_IN_SECONDS );
set_transient( $transient_name, $this->total_stock, DAY_IN_SECONDS * 30 );
}
}
@ -103,7 +103,7 @@ class WC_Product_Grouped extends WC_Product {
$this->children = get_posts( $args );
set_transient( $transient_name, $this->children, YEAR_IN_SECONDS );
set_transient( $transient_name, $this->children, DAY_IN_SECONDS * 30 );
}
}
return (array) $this->children;

View File

@ -66,7 +66,7 @@ class WC_Product_Variable extends WC_Product {
}
}
}
set_transient( $transient_name, $this->total_stock, YEAR_IN_SECONDS );
set_transient( $transient_name, $this->total_stock, DAY_IN_SECONDS * 30 );
}
}
return wc_stock_amount( $this->total_stock );
@ -147,7 +147,7 @@ class WC_Product_Variable extends WC_Product {
$this->children = get_posts( $args );
set_transient( $transient_name, $this->children, YEAR_IN_SECONDS );
set_transient( $transient_name, $this->children, DAY_IN_SECONDS * 30 );
}
}

View File

@ -518,7 +518,7 @@ class WC_Query {
)
);
set_transient( $transient_name, $unfiltered_product_ids, YEAR_IN_SECONDS );
set_transient( $transient_name, $unfiltered_product_ids, DAY_IN_SECONDS * 30 );
}
// Store the variable

View File

@ -138,7 +138,7 @@ function wc_get_product_ids_on_sale() {
$product_ids_on_sale = array_unique( array_map( 'absint', array_merge( wp_list_pluck( $on_sale_posts, 'ID' ), array_diff( wp_list_pluck( $on_sale_posts, 'post_parent' ), array( 0 ) ) ) ) );
set_transient( 'wc_products_onsale', $product_ids_on_sale, YEAR_IN_SECONDS );
set_transient( 'wc_products_onsale', $product_ids_on_sale, DAY_IN_SECONDS * 30 );
return $product_ids_on_sale;
}
@ -181,7 +181,7 @@ function wc_get_featured_product_ids() {
$parent_ids = array_values( $featured );
$featured_product_ids = array_unique( array_merge( $product_ids, $parent_ids ) );
set_transient( 'wc_featured_products', $featured_product_ids, YEAR_IN_SECONDS );
set_transient( 'wc_featured_products', $featured_product_ids, DAY_IN_SECONDS * 30 );
return $featured_product_ids;
}

View File

@ -1337,7 +1337,7 @@ if ( ! function_exists( 'woocommerce_products_will_display' ) ) {
}
}
set_transient( $transient_name, $products_will_display, YEAR_IN_SECONDS );
set_transient( $transient_name, $products_will_display, DAY_IN_SECONDS * 30 );
return $products_will_display;
}

View File

@ -589,7 +589,7 @@ function wc_change_term_counts( $terms, $taxonomies ) {
// Update transient
if ( $term_counts != $o_term_counts ) {
set_transient( 'wc_term_counts', $term_counts, YEAR_IN_SECONDS );
set_transient( 'wc_term_counts', $term_counts, DAY_IN_SECONDS * 30 );
}
return $terms;

View File

@ -200,7 +200,7 @@ class WC_Widget_Layered_Nav extends WC_Widget {
$_products_in_term = get_objects_in_term( $term->term_id, $taxonomy );
set_transient( $transient_name, $_products_in_term, YEAR_IN_SECONDS );
set_transient( $transient_name, $_products_in_term, DAY_IN_SECONDS * 30 );
}
$option_is_set = ( isset( $_chosen_attributes[ $taxonomy ] ) && in_array( $term->term_id, $_chosen_attributes[ $taxonomy ]['terms'] ) );

View File

@ -140,6 +140,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Fix - Saving an order needs to save the discount amount ex. tax like the cart.
* Tweak - Show discounts inc. tax when showing order totals inc. tax.
* Tweak - Use 30 days instead of year for transients to avoid bugs in memcache plugins.
= 2.3.5 - 20/02/2015 =
* Fix - Plain text address formatting.