Make WordPress Core

Ticket #37464: 37464.2.diff

File 37464.2.diff, 6.3 KB (added by desrosj, 5 years ago)
  • src/wp-includes/class-wp-comment-query.php

     
    393393
    394394                // $args can include anything. Only use the args defined in the query_var_defaults to compute the key.
    395395                $key = md5( serialize( wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ) ) );
    396                 $last_changed = wp_cache_get( 'last_changed', 'comment' );
    397                 if ( ! $last_changed ) {
    398                         $last_changed = microtime();
    399                         wp_cache_set( 'last_changed', $last_changed, 'comment' );
    400                 }
     396                $last_changed = wp_cache_get_last_changed( 'comment' );
    401397
     398
    402399                $cache_key   = "get_comments:$key:$last_changed";
    403400                $cache_value = wp_cache_get( $cache_key, 'comment' );
    404401                if ( false === $cache_value ) {
     
    972969                }
    973970
    974971                $key = md5( serialize( wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ) ) );
    975                 $last_changed = wp_cache_get( 'last_changed', 'comment' );
    976                 if ( ! $last_changed ) {
    977                         $last_changed = microtime();
    978                         wp_cache_set( 'last_changed', $last_changed, 'comment' );
    979                 }
     972                $last_changed = wp_cache_get_last_changed( 'comment' );
    980973
    981974                // Fetch an entire level of the descendant tree at a time.
    982975                $level = 0;
  • src/wp-includes/class-wp-network-query.php

     
    209209
    210210                // $args can include anything. Only use the args defined in the query_var_defaults to compute the key.
    211211                $key = md5( serialize( wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ) ) );
    212                 $last_changed = wp_cache_get( 'last_changed', 'networks' );
    213                 if ( ! $last_changed ) {
    214                         $last_changed = microtime();
    215                         wp_cache_set( 'last_changed', $last_changed, 'networks' );
    216                 }
     212                $last_changed = wp_cache_get_last_changed( 'networks' );
    217213
    218214                $cache_key = "get_network_ids:$key:$last_changed";
    219215                $cache_value = wp_cache_get( $cache_key, 'networks' );
  • src/wp-includes/class-wp-site-query.php

     
    245245
    246246                // $args can include anything. Only use the args defined in the query_var_defaults to compute the key.
    247247                $key = md5( serialize( wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ) ) );
    248                 $last_changed = wp_cache_get( 'last_changed', 'sites' );
    249                 if ( ! $last_changed ) {
    250                         $last_changed = microtime();
    251                         wp_cache_set( 'last_changed', $last_changed, 'sites' );
    252                 }
     248                $last_changed = wp_cache_get_last_changed( 'sites' );
    253249
    254250                $cache_key = "get_sites:$key:$last_changed";
    255251                $cache_value = wp_cache_get( $cache_key, 'sites' );
  • src/wp-includes/class-wp-term-query.php

     
    673673
    674674                // $args can be anything. Only use the args defined in defaults to compute the key.
    675675                $key = md5( serialize( wp_array_slice_assoc( $args, array_keys( $this->query_var_defaults ) ) ) . serialize( $taxonomies ) . $this->request );
    676                 $last_changed = wp_cache_get( 'last_changed', 'terms' );
    677                 if ( ! $last_changed ) {
    678                         $last_changed = microtime();
    679                         wp_cache_set( 'last_changed', $last_changed, 'terms' );
    680                 }
     676                $last_changed = wp_cache_get_last_changed( 'terms' );
    681677                $cache_key = "get_terms:$key:$last_changed";
    682678                $cache = wp_cache_get( $cache_key, 'terms' );
    683679                if ( false !== $cache ) {
  • src/wp-includes/functions.php

     
    55295529
    55305530        return false;
    55315531}
     5532
     5533/**
     5534 * Get last changed date for the specified cache group.
     5535 *
     5536 * @since 4.7.0
     5537 *
     5538 * @param $group Where the cache contents are grouped.
     5539 *
     5540 * @return string $last_changed UNIX timestamp with microseconds representing when the group was last changed.
     5541 */
     5542function wp_cache_get_last_changed( $group ) {
     5543        $last_changed = wp_cache_get( 'last_changed', $group );
     5544
     5545        if ( ! $last_changed ) {
     5546                $last_changed = microtime();
     5547                wp_cache_set( 'last_changed', $last_changed, $group );
     5548        }
     5549
     5550        return $last_changed;
     5551}
     5552 No newline at end of file
  • src/wp-includes/general-template.php

     
    17051705
    17061706        $output = '';
    17071707
    1708         $last_changed = wp_cache_get( 'last_changed', 'posts' );
    1709         if ( ! $last_changed ) {
    1710                 $last_changed = microtime();
    1711                 wp_cache_set( 'last_changed', $last_changed, 'posts' );
    1712         }
     1708        $last_changed = wp_cache_get_last_changed( 'posts' );
    17131709
    17141710        $limit = $r['limit'];
    17151711
  • src/wp-includes/post.php

     
    41114111function get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' ) {
    41124112        global $wpdb;
    41134113
    4114         $last_changed = wp_cache_get( 'last_changed', 'posts' );
    4115         if ( false === $last_changed ) {
    4116                 $last_changed = microtime();
    4117                 wp_cache_set( 'last_changed', $last_changed, 'posts' );
    4118         }
     4114        $last_changed = wp_cache_get_last_changed( 'posts' );
    41194115
    41204116        $hash = md5( $page_path . serialize( $post_type ) );
    41214117        $cache_key = "get_page_by_path:$hash:$last_changed";
     
    44494445
    44504446        // $args can be whatever, only use the args defined in defaults to compute the key.
    44514447        $key = md5( serialize( wp_array_slice_assoc( $r, array_keys( $defaults ) ) ) );
    4452         $last_changed = wp_cache_get( 'last_changed', 'posts' );
    4453         if ( ! $last_changed ) {
    4454                 $last_changed = microtime();
    4455                 wp_cache_set( 'last_changed', $last_changed, 'posts' );
    4456         }
     4448        $last_changed = wp_cache_get_last_changed( 'posts' );
    44574449
    44584450        $cache_key = "get_pages:$key:$last_changed";
    44594451        if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) {