Make WordPress Core


Ignore:
Timestamp:
11/14/2014 09:52:23 PM (12 years ago)
Author:
boonebgorges
Message:

Flush cache for newly created term in _split_shared_term().

The term itself does not have any cached values yet, but in some cases the new
term's taxonomy may need its cached hierarchy to be refreshed as a result of
the term splitting.

Props jorbin.
See #30335.

File:
1 edited

Legend:

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

    r30344 r30347  
    40974097        $children_tt_ids = $wpdb->get_col( $wpdb->prepare( "SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE taxonomy = %s AND parent = %d", $term_taxonomy->taxonomy, $term_id ) );
    40984098
    4099         foreach ( $children_tt_ids as $child_tt_id ) {
    4100                 $wpdb->update( $wpdb->term_taxonomy,
    4101                         array( 'parent' => $new_term_id ),
    4102                         array( 'term_taxonomy_id' => $child_tt_id )
    4103                 );
    4104                 clean_term_cache( $term_id, $term_taxonomy->taxonomy );
     4099        if ( ! empty( $children_tt_ids ) ) {
     4100                foreach ( $children_tt_ids as $child_tt_id ) {
     4101                        $wpdb->update( $wpdb->term_taxonomy,
     4102                                array( 'parent' => $new_term_id ),
     4103                                array( 'term_taxonomy_id' => $child_tt_id )
     4104                        );
     4105                        clean_term_cache( $term_id, $term_taxonomy->taxonomy );
     4106                }
     4107        } else {
     4108                // If the term has no children, we must force its taxonomy cache to be rebuilt separately.
     4109                clean_term_cache( $new_term_id, $term_taxonomy->taxonomy );
    41054110        }
    41064111
Note: See TracChangeset for help on using the changeset viewer.