Improve cache invalidation when splitting shared terms.
This changeset addresses two related issues: * When splitting shared terms from hierarchical taxonomies, the process of regenerating the taxonomy hierarchy (`_get_taxonomy_hierarchy()`) requires recursive calls to `get_terms()` in order to descend the tree. By waiting until all shared terms in a term group have been invalidated before regenerating their taxonomy hierarchies, we avoid certain race conditions. * Previously, a coding error prevented single-term caches from being invalidated for children of split terms. This error dates from [31418]. See #37189. Built from https://develop.svn.wordpress.org/trunk@40920 git-svn-id: http://core.svn.wordpress.org/trunk@40770 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
989427d598
commit
8ca91024e8
|
@ -3548,19 +3548,27 @@ function _split_shared_term( $term_id, $term_taxonomy_id, $record = true ) {
|
||||||
array( 'parent' => $new_term_id ),
|
array( 'parent' => $new_term_id ),
|
||||||
array( 'term_taxonomy_id' => $child_tt_id )
|
array( 'term_taxonomy_id' => $child_tt_id )
|
||||||
);
|
);
|
||||||
clean_term_cache( $term_id, $term_taxonomy->taxonomy );
|
clean_term_cache( (int) $child_tt_id, '', false );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If the term has no children, we must force its taxonomy cache to be rebuilt separately.
|
// 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_term_cache( $new_term_id, $term_taxonomy->taxonomy, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clean_term_cache( $term_id, $term_taxonomy->taxonomy, false );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Taxonomy cache clearing is delayed to avoid race conditions that may occur when
|
||||||
|
* regenerating the taxonomy's hierarchy tree.
|
||||||
|
*/
|
||||||
|
$taxonomies_to_clean = array( $term_taxonomy->taxonomy );
|
||||||
|
|
||||||
// Clean the cache for term taxonomies formerly shared with the current term.
|
// Clean the cache for term taxonomies formerly shared with the current term.
|
||||||
$shared_term_taxonomies = $wpdb->get_row( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d", $term_id ) );
|
$shared_term_taxonomies = $wpdb->get_col( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d", $term_id ) );
|
||||||
if ( $shared_term_taxonomies ) {
|
$taxonomies_to_clean = array_merge( $taxonomies_to_clean, $shared_term_taxonomies );
|
||||||
foreach ( $shared_term_taxonomies as $shared_term_taxonomy ) {
|
|
||||||
clean_term_cache( $term_id, $shared_term_taxonomy );
|
foreach ( $taxonomies_to_clean as $taxonomy_to_clean ) {
|
||||||
}
|
clean_taxonomy_cache( $taxonomy_to_clean );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep a record of term_ids that have been split, keyed by old term_id. See wp_get_split_term().
|
// Keep a record of term_ids that have been split, keyed by old term_id. See wp_get_split_term().
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.9-alpha-40919';
|
$wp_version = '4.9-alpha-40920';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue