From 8f0ab2efb8c54f07418eed60733840a28905147a Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Mon, 5 Feb 2018 04:10:30 +0000 Subject: [PATCH] Taxonomy: Stop warming term meta cache unnecessarily. Prevent several core function calls to `get_terms()` from warming the term meta cache. Props peterwilsoncc, boonebgorges, jrf. Fixes #43142. Built from https://develop.svn.wordpress.org/trunk@42649 git-svn-id: http://core.svn.wordpress.org/trunk@42478 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy.php | 33 ++++++++++++++++++++++----------- wp-includes/version.php | 2 +- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 293b18b8b6..57e42e275a 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -2147,9 +2147,10 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) { */ $name_matches = get_terms( $taxonomy, array( - 'name' => $name, - 'hide_empty' => false, - 'parent' => $args['parent'], + 'name' => $name, + 'hide_empty' => false, + 'parent' => $args['parent'], + 'update_term_meta_cache' => false, ) ); @@ -2173,8 +2174,9 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) { if ( is_taxonomy_hierarchical( $taxonomy ) ) { $siblings = get_terms( $taxonomy, array( - 'get' => 'all', - 'parent' => $parent, + 'get' => 'all', + 'parent' => $parent, + 'update_term_meta_cache' => false, ) ); @@ -2364,8 +2366,9 @@ function wp_set_object_terms( $object_id, $terms, $taxonomy, $append = false ) { if ( ! $append ) { $old_tt_ids = wp_get_object_terms( $object_id, $taxonomy, array( - 'fields' => 'tt_ids', - 'orderby' => 'none', + 'fields' => 'tt_ids', + 'orderby' => 'none', + 'update_term_meta_cache' => false, ) ); } else { @@ -2454,7 +2457,14 @@ function wp_set_object_terms( $object_id, $terms, $taxonomy, $append = false ) { if ( ! $append && isset( $t->sort ) && $t->sort ) { $values = array(); $term_order = 0; - $final_tt_ids = wp_get_object_terms( $object_id, $taxonomy, array( 'fields' => 'tt_ids' ) ); + $final_tt_ids = wp_get_object_terms( + $object_id, + $taxonomy, + array( + 'fields' => 'tt_ids', + 'update_term_meta_cache' => false, + ) + ); foreach ( $tt_ids as $tt_id ) { if ( in_array( $tt_id, $final_tt_ids ) ) { $values[] = $wpdb->prepare( '(%d, %d, %d)', $object_id, $tt_id, ++$term_order ); @@ -3382,9 +3392,10 @@ function _get_term_hierarchy( $taxonomy ) { $children = array(); $terms = get_terms( $taxonomy, array( - 'get' => 'all', - 'orderby' => 'id', - 'fields' => 'id=>parent', + 'get' => 'all', + 'orderby' => 'id', + 'fields' => 'id=>parent', + 'update_term_meta_cache' => false, ) ); foreach ( $terms as $term_id => $parent ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index c13a1e696b..02e9114cea 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '5.0-alpha-42648'; +$wp_version = '5.0-alpha-42649'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.