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.



git-svn-id: https://develop.svn.wordpress.org/trunk@42649 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Wilson 2018-02-05 04:09:27 +00:00
parent f317869c7f
commit 5c378e02dd
1 changed files with 22 additions and 11 deletions

View File

@ -2147,9 +2147,10 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
*/ */
$name_matches = get_terms( $name_matches = get_terms(
$taxonomy, array( $taxonomy, array(
'name' => $name, 'name' => $name,
'hide_empty' => false, 'hide_empty' => false,
'parent' => $args['parent'], '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 ) ) { if ( is_taxonomy_hierarchical( $taxonomy ) ) {
$siblings = get_terms( $siblings = get_terms(
$taxonomy, array( $taxonomy, array(
'get' => 'all', 'get' => 'all',
'parent' => $parent, 'parent' => $parent,
'update_term_meta_cache' => false,
) )
); );
@ -2364,8 +2366,9 @@ function wp_set_object_terms( $object_id, $terms, $taxonomy, $append = false ) {
if ( ! $append ) { if ( ! $append ) {
$old_tt_ids = wp_get_object_terms( $old_tt_ids = wp_get_object_terms(
$object_id, $taxonomy, array( $object_id, $taxonomy, array(
'fields' => 'tt_ids', 'fields' => 'tt_ids',
'orderby' => 'none', 'orderby' => 'none',
'update_term_meta_cache' => false,
) )
); );
} else { } else {
@ -2454,7 +2457,14 @@ function wp_set_object_terms( $object_id, $terms, $taxonomy, $append = false ) {
if ( ! $append && isset( $t->sort ) && $t->sort ) { if ( ! $append && isset( $t->sort ) && $t->sort ) {
$values = array(); $values = array();
$term_order = 0; $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 ) { foreach ( $tt_ids as $tt_id ) {
if ( in_array( $tt_id, $final_tt_ids ) ) { if ( in_array( $tt_id, $final_tt_ids ) ) {
$values[] = $wpdb->prepare( '(%d, %d, %d)', $object_id, $tt_id, ++$term_order ); $values[] = $wpdb->prepare( '(%d, %d, %d)', $object_id, $tt_id, ++$term_order );
@ -3382,9 +3392,10 @@ function _get_term_hierarchy( $taxonomy ) {
$children = array(); $children = array();
$terms = get_terms( $terms = get_terms(
$taxonomy, array( $taxonomy, array(
'get' => 'all', 'get' => 'all',
'orderby' => 'id', 'orderby' => 'id',
'fields' => 'id=>parent', 'fields' => 'id=>parent',
'update_term_meta_cache' => false,
) )
); );
foreach ( $terms as $term_id => $parent ) { foreach ( $terms as $term_id => $parent ) {