WordPress.org

Make WordPress Core

Ticket #23448: 23448.diff

File 23448.diff, 3.5 KB (added by westi, 5 years ago)

Switch to time() based last_changed

  • wp-includes/taxonomy.php

     
    12421242        $key = md5( serialize( compact(array_keys($defaults)) ) . serialize( $taxonomies ) . $filter_key );
    12431243        $last_changed = wp_cache_get( 'last_changed', 'terms' );
    12441244        if ( ! $last_changed ) {
    1245                 $last_changed = 1;
     1245                $last_changed = time();
    12461246                wp_cache_set( 'last_changed', $last_changed, 'terms' );
    12471247        }
    12481248        $cache_key = "get_terms:$key:$last_changed";
     
    27112711                do_action('clean_term_cache', $ids, $taxonomy);
    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', time(), 'terms' );
    27202715}
    27212716
    27222717/**
  • wp-includes/post.php

     
    36533653        $key = md5( serialize( compact(array_keys($defaults)) ) );
    36543654        $last_changed = wp_cache_get( 'last_changed', 'posts' );
    36553655        if ( ! $last_changed ) {
    3656                 $last_changed = 1;
     3656                $last_changed = time();
    36573657                wp_cache_set( 'last_changed', $last_changed, 'posts' );
    36583658        }
    36593659
     
    46724672                do_action( 'clean_page_cache', $post->ID );
    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', time(), 'posts' );
    46814676}
    46824677
    46834678/**
  • wp-includes/comment.php

     
    251251                $key = md5( serialize( compact(array_keys($defaults)) )  );
    252252                $last_changed = wp_cache_get( 'last_changed', 'comment' );
    253253                if ( ! $last_changed ) {
    254                         $last_changed = 1;
     254                        $last_changed = time();
    255255                        wp_cache_set( 'last_changed', $last_changed, 'comment' );
    256256                }
    257257                $cache_key = "get_comments:$key:$last_changed";
     
    12921292        $comment = get_comment($id);
    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', time(), 'comment' );
    13011296
    13021297        return $id;
    13031298}
     
    20502045        foreach ( (array) $ids as $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', time(), 'comment' );
    20592049}
    20602050
    20612051/**
  • wp-includes/general-template.php

     
    919919
    920920        $last_changed = wp_cache_get( 'last_changed', 'posts' );
    921921        if ( ! $last_changed ) {
    922                 $last_changed = 1;
     922                $last_changed = time();
    923923                wp_cache_set( 'last_changed', $last_changed, 'posts' );
    924924        }
    925925