From 7de3499949c8412951e66184f87b7bcca251bf42 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Tue, 13 Oct 2015 02:58:24 +0000 Subject: [PATCH] In `get_terms()`, don't store `WP_Term` objects in cache. Fixes #34282. Built from https://develop.svn.wordpress.org/trunk@35117 git-svn-id: http://core.svn.wordpress.org/trunk@35082 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy-functions.php | 9 +++++++-- wp-includes/version.php | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/wp-includes/taxonomy-functions.php b/wp-includes/taxonomy-functions.php index 0c89ac1e51..88f944edc2 100644 --- a/wp-includes/taxonomy-functions.php +++ b/wp-includes/taxonomy-functions.php @@ -1155,6 +1155,9 @@ function get_terms( $taxonomies, $args = '' ) { $cache_key = "get_terms:$key:$last_changed"; $cache = wp_cache_get( $cache_key, 'terms' ); if ( false !== $cache ) { + if ( 'all' === $args['fields'] ) { + $cache = array_map( 'get_term', $cache ); + } /** * Filter the given taxonomy's terms cache. @@ -1494,8 +1497,6 @@ function get_terms( $taxonomies, $args = '' ) { foreach ( $terms as $term ) { $_terms[ $term->term_id ] = $term->slug; } - } else { - $_terms = array_map( 'get_term', $terms ); } if ( ! empty( $_terms ) ) { @@ -1508,6 +1509,10 @@ function get_terms( $taxonomies, $args = '' ) { wp_cache_add( $cache_key, $terms, 'terms', DAY_IN_SECONDS ); + if ( 'all' === $_fields ) { + $terms = array_map( 'get_term', $terms ); + } + /** This filter is documented in wp-includes/taxonomy */ return apply_filters( 'get_terms', $terms, $taxonomies, $args ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index d8a3d16ad8..691aab1c6f 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-35116'; +$wp_version = '4.4-alpha-35117'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.