diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 458b47ea9b..775d5f4b95 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -4742,21 +4742,3 @@ function wp_validate_boolean( $var ) { return (bool) $var; } - -/** - * Helper function to retrieve an incrementer identified by $group - * - * @since 4.1.0 - * - * @param string $group The cache group for the incrementer. - * @param bool $force Whether or not to generate a new incrementor. - * @return int The timestamp representing 'last_changed'. - */ -function wp_get_last_changed( $group, $force = false ) { - $last_changed = wp_cache_get( 'last_changed', $group ); - if ( ! $last_changed || true === $force ) { - $last_changed = microtime(); - wp_cache_set( 'last_changed', $last_changed, $group ); - } - return $last_changed; -} \ No newline at end of file diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index defc36cd8e..22d74cd23e 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -1291,11 +1291,11 @@ function get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') { return $error; } - $group = $taxonomy . ':' . wp_get_last_changed( 'terms' ); + $incrementor = wp_cache_get( 'last_changed', 'terms' ); if ( is_object($term) && empty($term->filter) ) { - wp_cache_add( $term->term_id, $term, $taxonomy ); - wp_cache_add( "slug:{$term->slug}", $term->term_id, $group ); - wp_cache_add( "name:" . md5( $term->name ), $term->term_id, $group ); + wp_cache_add( $term->term_id, $term, $taxonomy . ':terms:' . $incrementor ); + wp_cache_add( $term->slug, $term->term_id, $taxonomy . ':slugs:' . $incrementor ); + wp_cache_add( $term->name, $term->term_id, $taxonomy . ':names:' . $incrementor ); $_term = $term; } else { if ( is_object($term) ) @@ -1306,9 +1306,9 @@ function get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') { $_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND t.term_id = %d LIMIT 1", $taxonomy, $term) ); if ( ! $_term ) return null; - wp_cache_add( $term, $_term, $taxonomy ); - wp_cache_add( "slug:{$_term->slug}", $term, $group ); - wp_cache_add( "name:" . md5( $_term->name ), $term, $group ); + wp_cache_add( $term, $_term, $taxonomy . ':terms:' . $incrementor ); + wp_cache_add( $_term->slug, $term, $taxonomy . ':slugs:' . $incrementor ); + wp_cache_add( $_term->name, $term, $taxonomy . ':names:' . $incrementor ); } } @@ -1381,14 +1381,14 @@ function get_term_by($field, $value, $taxonomy, $output = OBJECT, $filter = 'raw return false; $cache = false; - $group = $taxonomy . ':' . wp_get_last_changed( 'terms' ); + $incrementor = wp_cache_get( 'last_changed', 'terms' ); if ( 'slug' == $field ) { $field = 't.slug'; $value = sanitize_title($value); if ( empty($value) ) return false; - $term_id = wp_cache_get( "slug:{$value}", $group ); + $term_id = wp_cache_get( $value, $taxonomy . ':slugs:' . $incrementor ); if ( $term_id ) { $value = $term_id; $cache = true; @@ -1397,7 +1397,7 @@ function get_term_by($field, $value, $taxonomy, $output = OBJECT, $filter = 'raw // Assume already escaped $value = wp_unslash($value); $field = 't.name'; - $term_id = wp_cache_get( "name:" . md5( $value ), $group ); + $term_id = wp_cache_get( $value, $taxonomy . ':names:' . $incrementor ); if ( $term_id ) { $value = $term_id; $cache = true; @@ -1429,9 +1429,9 @@ function get_term_by($field, $value, $taxonomy, $output = OBJECT, $filter = 'raw $term = sanitize_term($term, $taxonomy, $filter); - wp_cache_add( $term->term_id, $term, $taxonomy ); - wp_cache_add( "slug:{$term->slug}", $term->term_id, $group ); - wp_cache_add( "name:" . md5( $term->name ), $term->term_id, $group ); + wp_cache_add( $term->term_id, $term, $taxonomy . ':terms:' . $incrementor ); + wp_cache_add( $term->slug, $term->term_id, $taxonomy . ':slugs:' . $incrementor ); + wp_cache_add( $term->name, $term->term_id, $taxonomy . ':names:' . $incrementor ); if ( $output == OBJECT ) { return $term; @@ -3670,7 +3670,7 @@ function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true) { do_action( 'clean_term_cache', $ids, $taxonomy ); } - wp_get_last_changed( 'terms', true ); + wp_cache_set( 'last_changed', microtime(), 'terms' ); } /** @@ -3776,10 +3776,11 @@ function update_term_cache($terms, $taxonomy = '') { if ( empty($term_taxonomy) ) $term_taxonomy = $term->taxonomy; - wp_cache_add( $term->term_id, $term, $term_taxonomy ); - $group = $term_taxonomy . ':' . wp_get_last_changed( 'terms', true ); - wp_cache_add( "slug:{$term->slug}", $term->term_id, $group ); - wp_cache_add( "name:" . md5( $term->name ), $term->term_id, $group ); + $incrementor = wp_cache_set( 'last_changed', microtime(), 'terms' ); + + wp_cache_add( $term->term_id, $term, $term_taxonomy . ':terms:' . $incrementor ); + wp_cache_add( $term->slug, $term->term_id, $taxonomy . ':slugs:' . $incrementor ); + wp_cache_add( $term->name, $term->term_id, $taxonomy . ':names:' . $incrementor ); } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 3c6d9ce753..ef26277c45 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.1-alpha-30072'; +$wp_version = '4.1-alpha-30073'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.