From f08e5c2d80568e2413f915394aaad7f2657f0e90 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Sat, 3 Oct 2015 21:19:23 +0000 Subject: [PATCH] Update the taxonomy relationship cache in `is_object_in_term()`. This function attempts to read from the relationship cache, and uses any data it finds. If it finds no data, it does a query for the data it needs. Since we are going to the trouble to query for the relationships, and since we are already using cached data when available, let's go ahead and cache it for later use. Props joehoyle, boonebgorges. Fixes #32044. Built from https://develop.svn.wordpress.org/trunk@34812 git-svn-id: http://core.svn.wordpress.org/trunk@34777 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy-functions.php | 6 ++++-- wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/wp-includes/taxonomy-functions.php b/wp-includes/taxonomy-functions.php index 8de369c2db..7da100b45f 100644 --- a/wp-includes/taxonomy-functions.php +++ b/wp-includes/taxonomy-functions.php @@ -4390,8 +4390,10 @@ function is_object_in_term( $object_id, $taxonomy, $terms = null ) { return new WP_Error( 'invalid_object', __( 'Invalid object ID' ) ); $object_terms = get_object_term_cache( $object_id, $taxonomy ); - if ( false === $object_terms ) - $object_terms = wp_get_object_terms( $object_id, $taxonomy, array( 'update_term_meta_cache' => false ) ); + if ( false === $object_terms ) { + $object_terms = wp_get_object_terms( $object_id, $taxonomy, array( 'update_term_meta_cache' => false ) ); + wp_cache_set( $object_id, $object_terms, "{$taxonomy}_relationships" ); + } if ( is_wp_error( $object_terms ) ) return $object_terms; diff --git a/wp-includes/version.php b/wp-includes/version.php index 290fb1015d..6c1ac9c12f 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34811'; +$wp_version = '4.4-alpha-34812'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.