Make WordPress Core


Ignore:
Timestamp:
02/11/2013 06:08:14 PM (14 years ago)
Author:
ryan
Message:

Use microtime() instead of incrementors for last_changed to to avoid race conditions with cache evictions.

Props westi
fixes #23448

File:
1 edited

Legend:

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

    r23341 r23401  
    252252                $last_changed = wp_cache_get( 'last_changed', 'comment' );
    253253                if ( ! $last_changed ) {
    254                         $last_changed = 1;
     254                        $last_changed = microtime();
    255255                        wp_cache_set( 'last_changed', $last_changed, 'comment' );
    256256                }
    … …  
    12931293        do_action('wp_insert_comment', $id, $comment);
    12941294
    1295         if ( function_exists( 'wp_cache_incr' ) ) {
    1296                 wp_cache_incr( 'last_changed', 1, 'comment' );
    1297         } else {
    1298                 $last_changed = wp_cache_get( 'last_changed', 'comment' );
    1299                 wp_cache_set( 'last_changed', $last_changed + 1, 'comment' );
    1300         }
     1295        wp_cache_set( 'last_changed', microtime(), 'comment' );
    13011296
    13021297        return $id;
    … …  
    20512046                wp_cache_delete($id, 'comment');
    20522047
    2053         if ( function_exists( 'wp_cache_incr' ) ) {
    2054                 wp_cache_incr( 'last_changed', 1, 'comment' );
    2055         } else {
    2056                 $last_changed = wp_cache_get( 'last_changed', 'comment' );
    2057                 wp_cache_set( 'last_changed', $last_changed + 1, 'comment' );
    2058         }
     2048        wp_cache_set( 'last_changed', microtime(), 'comment' );
    20592049}
    20602050
Note: See TracChangeset for help on using the changeset viewer.