Make WordPress Core


Ignore:
Timestamp:
05/26/2016 04:49:10 AM (10 years ago)
Author:
boonebgorges
Message:

Store only term IDs in object term relationships caches.

Previously, objects containing all data about a term were stored in each
object's term cache. Besides being wasteful, this approach caused invalidation
issues, as when a modified term count required a flush for all objects
belonging to the term.

Backward compatibility is maintained for plugins that continue to put object
data directly into the {$taxonomy}_relationships cache bucket.

Fixes #36814.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/category-template.php

    r37571 r37573  
    11881188                $terms = wp_get_object_terms( $post->ID, $taxonomy );
    11891189                if ( ! is_wp_error( $terms ) ) {
    1190                         $to_cache = array();
    1191                         foreach ( $terms as $key => $term ) {
    1192                                 $to_cache[ $key ] = $term->data;
    1193                         }
    1194                         wp_cache_add( $post->ID, $to_cache, $taxonomy . '_relationships' );
    1195                 }
    1196         }
    1197 
    1198         if ( ! is_wp_error( $terms ) ) {
    1199                 $terms = array_map( 'get_term', $terms );
     1190                        $term_ids = wp_list_pluck( $terms, 'term_id' );
     1191                        wp_cache_add( $post->ID, $term_ids, $taxonomy . '_relationships' );
     1192                }
    12001193        }
    12011194
Note: See TracChangeset for help on using the changeset viewer.