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.
Built from https://develop.svn.wordpress.org/trunk@30347


git-svn-id: http://core.svn.wordpress.org/trunk@30346 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2014-11-14 21:53:22 +00:00
parent e61bebdbfc
commit 866cfdf19b
2 changed files with 12 additions and 7 deletions

View File

@ -4096,12 +4096,17 @@ function _split_shared_term( $term_id, $term_taxonomy_id ) {
$term_taxonomy = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $term_taxonomy_id ) );
$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 ) );
foreach ( $children_tt_ids as $child_tt_id ) {
$wpdb->update( $wpdb->term_taxonomy,
array( 'parent' => $new_term_id ),
array( 'term_taxonomy_id' => $child_tt_id )
);
clean_term_cache( $term_id, $term_taxonomy->taxonomy );
if ( ! empty( $children_tt_ids ) ) {
foreach ( $children_tt_ids as $child_tt_id ) {
$wpdb->update( $wpdb->term_taxonomy,
array( 'parent' => $new_term_id ),
array( 'term_taxonomy_id' => $child_tt_id )
);
clean_term_cache( $term_id, $term_taxonomy->taxonomy );
}
} else {
// If the term has no children, we must force its taxonomy cache to be rebuilt separately.
clean_term_cache( $new_term_id, $term_taxonomy->taxonomy );
}
// Clean the cache for term taxonomies formerly shared with the current term.

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.1-alpha-30346';
$wp_version = '4.1-alpha-30347';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.