Make WordPress Core

Changeset 23401


Ignore:
Timestamp:
02/11/2013 06:08:14 PM (12 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

Location:
trunk/wp-includes
Files:
4 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
  • trunk/wp-includes/general-template.php

    r23385 r23401  
    920920    $last_changed = wp_cache_get( 'last_changed', 'posts' );
    921921    if ( ! $last_changed ) {
    922         $last_changed = 1;
     922        $last_changed = microtime();
    923923        wp_cache_set( 'last_changed', $last_changed, 'posts' );
    924924    }
  • trunk/wp-includes/post.php

    r23387 r23401  
    36543654    $last_changed = wp_cache_get( 'last_changed', 'posts' );
    36553655    if ( ! $last_changed ) {
    3656         $last_changed = 1;
     3656        $last_changed = microtime();
    36573657        wp_cache_set( 'last_changed', $last_changed, 'posts' );
    36583658    }
     
    46734673    }
    46744674
    4675     if ( function_exists( 'wp_cache_incr' ) ) {
    4676         wp_cache_incr( 'last_changed', 1, 'posts' );
    4677     } else {
    4678         $last_changed = wp_cache_get( 'last_changed', 'posts' );
    4679         wp_cache_set( 'last_changed', $last_changed + 1, 'posts' );
    4680     }
     4675    wp_cache_set( 'last_changed', microtime(), 'posts' );
    46814676}
    46824677
  • trunk/wp-includes/taxonomy.php

    r23398 r23401  
    12431243    $last_changed = wp_cache_get( 'last_changed', 'terms' );
    12441244    if ( ! $last_changed ) {
    1245         $last_changed = 1;
     1245        $last_changed = microtime();
    12461246        wp_cache_set( 'last_changed', $last_changed, 'terms' );
    12471247    }
     
    27122712    }
    27132713
    2714     if ( function_exists( 'wp_cache_incr' ) ) {
    2715         wp_cache_incr( 'last_changed', 1, 'terms' );
    2716     } else {
    2717         $last_changed = wp_cache_get( 'last_changed', 'terms' );
    2718         wp_cache_set( 'last_changed', $last_changed + 1, 'terms' );
    2719     }
     2714    wp_cache_set( 'last_changed', microtime(), 'terms' );
    27202715}
    27212716
Note: See TracChangeset for help on using the changeset viewer.