Cleanup clean_term_cache(). Props Denis-de-Bernardy. see #11530

git-svn-id: https://develop.svn.wordpress.org/trunk@12510 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2009-12-23 14:37:21 +00:00
parent 02ce80a284
commit af9fafc779

View File

@ -1860,18 +1860,23 @@ function clean_term_cache($ids, $taxonomy = '') {
$taxonomies = array();
// If no taxonomy, assume tt_ids.
if ( empty($taxonomy) ) {
$tt_ids = implode(', ', $ids);
$tt_ids = array_map('intval', $ids);
$tt_ids = implode(', ', $tt_ids);
$terms = $wpdb->get_results("SELECT term_id, taxonomy FROM $wpdb->term_taxonomy WHERE term_taxonomy_id IN ($tt_ids)");
$ids = array();
foreach ( (array) $terms as $term ) {
$taxonomies[] = $term->taxonomy;
$ids[] = $term->term_id;
wp_cache_delete($term->term_id, $term->taxonomy);
}
$taxonomies = array_unique($taxonomies);
} else {
foreach ( $ids as $id ) {
wp_cache_delete($id, $taxonomy);
}
$taxonomies = array($taxonomy);
foreach ( $taxonomies as $taxonomy ) {
foreach ( $ids as $id ) {
wp_cache_delete($id, $taxonomy);
}
}
}
foreach ( $taxonomies as $taxonomy ) {
@ -1881,11 +1886,10 @@ function clean_term_cache($ids, $taxonomy = '') {
wp_cache_delete('all_ids', $taxonomy);
wp_cache_delete('get', $taxonomy);
delete_option("{$taxonomy}_children");
do_action('clean_term_cache', $ids, $taxonomy);
}
wp_cache_set('last_changed', time(), 'terms');
do_action('clean_term_cache', $ids, $taxonomy);
}