Use incrementors for cache invalidation in get_terms().
fixes #23326 see #23173 git-svn-id: http://core.svn.wordpress.org/trunk@23384 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
fe2dd7a2a3
commit
0f80568a7e
|
@ -1240,10 +1240,10 @@ function get_terms($taxonomies, $args = '') {
|
||||||
// $args can be whatever, only use the args defined in defaults to compute the key
|
// $args can be whatever, only use the args defined in defaults to compute the key
|
||||||
$filter_key = ( has_filter('list_terms_exclusions') ) ? serialize($GLOBALS['wp_filter']['list_terms_exclusions']) : '';
|
$filter_key = ( has_filter('list_terms_exclusions') ) ? serialize($GLOBALS['wp_filter']['list_terms_exclusions']) : '';
|
||||||
$key = md5( serialize( compact(array_keys($defaults)) ) . serialize( $taxonomies ) . $filter_key );
|
$key = md5( serialize( compact(array_keys($defaults)) ) . serialize( $taxonomies ) . $filter_key );
|
||||||
$last_changed = wp_cache_get('last_changed', 'terms');
|
$last_changed = wp_cache_get( 'last_changed', 'terms' );
|
||||||
if ( !$last_changed ) {
|
if ( ! $last_changed ) {
|
||||||
$last_changed = time();
|
$last_changed = 1;
|
||||||
wp_cache_set('last_changed', $last_changed, 'terms');
|
wp_cache_set( 'last_changed', $last_changed, 'terms' );
|
||||||
}
|
}
|
||||||
$cache_key = "get_terms:$key:$last_changed";
|
$cache_key = "get_terms:$key:$last_changed";
|
||||||
$cache = wp_cache_get( $cache_key, 'terms' );
|
$cache = wp_cache_get( $cache_key, 'terms' );
|
||||||
|
@ -2632,7 +2632,12 @@ function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true) {
|
||||||
do_action('clean_term_cache', $ids, $taxonomy);
|
do_action('clean_term_cache', $ids, $taxonomy);
|
||||||
}
|
}
|
||||||
|
|
||||||
wp_cache_set('last_changed', time(), 'terms');
|
if ( function_exists( 'wp_cache_incr' ) ) {
|
||||||
|
wp_cache_incr( 'last_changed', 1, 'terms' );
|
||||||
|
} else {
|
||||||
|
$last_changed = wp_cache_get( 'last_changed', 'terms' );
|
||||||
|
wp_cache_set( 'last_changed', $last_changed + 1, 'terms' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue