mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
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.
git-svn-id: https://develop.svn.wordpress.org/trunk@37573 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1187,18 +1187,11 @@ function get_the_terms( $post, $taxonomy ) {
|
||||
if ( false === $terms ) {
|
||||
$terms = wp_get_object_terms( $post->ID, $taxonomy );
|
||||
if ( ! is_wp_error( $terms ) ) {
|
||||
$to_cache = array();
|
||||
foreach ( $terms as $key => $term ) {
|
||||
$to_cache[ $key ] = $term->data;
|
||||
}
|
||||
wp_cache_add( $post->ID, $to_cache, $taxonomy . '_relationships' );
|
||||
$term_ids = wp_list_pluck( $terms, 'term_id' );
|
||||
wp_cache_add( $post->ID, $term_ids, $taxonomy . '_relationships' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! is_wp_error( $terms ) ) {
|
||||
$terms = array_map( 'get_term', $terms );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the list of terms attached to the given post.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user