WordPress.org

Make WordPress Core

Ticket #21760: 21760.11.diff

File 21760.11.diff, 2.2 KB (added by nacin, 6 years ago)

I don't see how this is any less DRY. It is certainly more obvious as to what is happening.

  • src/wp-includes/functions.php

     
    46294629
    46304630        return (bool) $var;
    46314631}
    4632 
    4633 /**
    4634  * Helper function to retrieve an incrementer identified by $group
    4635  *
    4636  * @since 4.1.0
    4637  *
    4638  * @param string $group The cache group for the incrementer.
    4639  * @param bool $force Whether or not to generate a new incrementor.
    4640  * @return int The timestamp representing 'last_changed'.
    4641  */
    4642 function wp_get_last_changed( $group, $force = false ) {
    4643         $last_changed = wp_cache_get( 'last_changed', $group );
    4644         if ( ! $last_changed || true === $force ) {
    4645                 $last_changed = microtime();
    4646                 wp_cache_set( 'last_changed', $last_changed, $group );
    4647         }
    4648         return $last_changed;
    4649 }
    4650  No newline at end of file
  • src/wp-includes/taxonomy.php

     
    12911291                return $error;
    12921292        }
    12931293
    1294         $group = $taxonomy . ':' . wp_get_last_changed( 'terms' );
     1294        $group = $taxonomy . ':' . wp_cache_get( 'last_changed', 'terms' );
    12951295        if ( is_object($term) && empty($term->filter) ) {
    12961296                wp_cache_add( $term->term_id, $term, $taxonomy );
    12971297                wp_cache_add( "slug:{$term->slug}", $term->term_id, $group );
     
    13811381                return false;
    13821382
    13831383        $cache = false;
    1384         $group = $taxonomy . ':' . wp_get_last_changed( 'terms' );
     1384        $group = $taxonomy . ':' . wp_cache_get( 'last_changed', 'terms' );
    13851385        if ( 'slug' == $field ) {
    13861386                $field = 't.slug';
    13871387                $value = sanitize_title($value);
     
    36573657                do_action( 'clean_term_cache', $ids, $taxonomy );
    36583658        }
    36593659
    3660         wp_get_last_changed( 'terms', true );
     3660        wp_cache_set( 'last_changed', microtime(), 'terms' );
    36613661}
    36623662
    36633663/**
     
    37643764                        $term_taxonomy = $term->taxonomy;
    37653765
    37663766                wp_cache_add( $term->term_id, $term, $term_taxonomy );
    3767                 $group = $term_taxonomy . ':' . wp_get_last_changed( 'terms', true );
     3767                $group = $term_taxonomy . ':' . wp_cache_set( 'last_changed', microtime(), 'terms' );
    37683768                wp_cache_add( "slug:{$term->slug}", $term->term_id, $group );
    37693769                wp_cache_add( "name:" . md5( $term->name ), $term->term_id, $group );
    37703770        }