From 36d9a3677e76e0040b48fcdf51c065063cc11ffe Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 23 Dec 2009 14:37:21 +0000 Subject: [PATCH] Cleanup clean_term_cache(). Props Denis-de-Bernardy. see #11530 git-svn-id: http://svn.automattic.com/wordpress/trunk@12510 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 98282027f..262149a8f 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -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); }