Make WordPress Core


Ignore:
Timestamp:
10/12/2015 03:12:29 PM (9 years ago)
Author:
boonebgorges
Message:

Don't cache WP_Term objects in wp_get_object_cache().

The data stored in the cache should be raw database query results, not
WP_Term objects (which may be modified by plugins, and may contain additional
properties that shouldn't be cached).

If term relationships caches were handled in wp_get_object_terms() - where
a database query takes place - it would be straightforward to cache raw data.
See #34239. Since, in fact, get_the_terms() caches the value it gets from
wp_get_object_terms(), we need a technique that allows us to get raw data
from a WP_Term object. Mirroring WP_User, we introduce a data property
on term objects, which get_the_terms() uses to fetch cacheable term info.

Fixes #34262.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/taxonomy-functions.php

    r35029 r35032  
    30633063
    30643064    // First, get all of the original args
    3065     $term = get_term( $term_id, $taxonomy, ARRAY_A );
     3065    $term = get_term( $term_id, $taxonomy );
    30663066
    30673067    if ( is_wp_error( $term ) ) {
     
    30733073    }
    30743074
     3075    $term = (array) $term->data;
     3076
    30753077    // Escape data pulled from DB.
    3076     $term = wp_slash($term);
     3078    $term = wp_slash( $term );
    30773079
    30783080    // Merge old and new args with new args overwriting old ones.
Note: See TracChangeset for help on using the changeset viewer.