WordPress.org

Make WordPress Core

Changeset 22080


Ignore:
Timestamp:
09/28/12 12:47:31 (3 years ago)
Author:
ryan
Message:

Invalidate the WP_Comment_Query:query() cache when comments are added. Switch last_changed to a counter incremented via wp_cache_incr().

fixes #22024

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/comment.php

    r22079 r22080  
    250250        // $args can be whatever, only use the args defined in defaults to compute the key 
    251251        $key = md5( serialize( compact(array_keys($defaults)) )  ); 
    252         $last_changed = wp_cache_get('last_changed', 'comment'); 
    253         if ( ! $last_changed ) { 
    254             $last_changed = time(); 
    255             wp_cache_set('last_changed', $last_changed, 'comment'); 
    256         } 
     252        $last_changed = wp_cache_get( 'last_changed', 'comment' ); 
     253        if ( ! $last_changed ) 
     254            $last_changed = wp_cache_set( 'last_changed', 1, 'comment' ); 
    257255        $cache_key = "get_comments:$key:$last_changed"; 
    258256 
    259         if ( $cache = wp_cache_get( $cache_key, 'comment' ) ) { 
     257        if ( $cache = wp_cache_get( $cache_key, 'comment' ) ) 
    260258            return $cache; 
    261         } 
    262259 
    263260        $post_id = absint($post_id); 
     
    12941291    do_action('wp_insert_comment', $id, $comment); 
    12951292 
     1293    wp_cache_incr( 'last_changed', 1, 'comment' ); 
     1294 
    12961295    return $id; 
    12971296} 
     
    19651964        wp_cache_delete($id, 'comment'); 
    19661965 
    1967     wp_cache_set('last_changed', time(), 'comment'); 
     1966    wp_cache_incr( 'last_changed', 1, 'comment' ); 
    19681967} 
    19691968 
Note: See TracChangeset for help on using the changeset viewer.