Changeset 5983
- Timestamp:
- 08/30/2007 12:34:55 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/taxonomy.php
r5979 r5983 641 641 wp_update_term_count($terms, $taxonomy); 642 642 } 643 644 // TODO clear the cache645 643 } 646 644 … … 871 869 } 872 870 873 // TODO clean old_terms. Need term_id instead of tt_id874 clean_term_cache($term_ids, $taxonomy);875 876 871 return $tt_ids; 877 872 } … … 950 945 951 946 $taxonomy = get_taxonomy($taxonomy); 952 if ( !empty($taxonomy->update_count_callback) ) 953 return call_user_func($taxonomy->update_count_callback, $terms); 954 955 // Default count updater 956 foreach ($terms as $term) { 957 $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = '$term'"); 958 $wpdb->query("UPDATE $wpdb->term_taxonomy SET count = '$count' WHERE term_taxonomy_id = '$term'"); 959 } 947 if ( !empty($taxonomy->update_count_callback) ) { 948 call_user_func($taxonomy->update_count_callback, $terms); 949 } else { 950 // Default count updater 951 foreach ($terms as $term) { 952 $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = '$term'"); 953 $wpdb->query("UPDATE $wpdb->term_taxonomy SET count = '$count' WHERE term_taxonomy_id = '$term'"); 954 } 955 956 } 957 958 clean_term_cache($terms); 960 959 961 960 return true; … … 982 981 } 983 982 984 function clean_term_cache($ids, $taxonomy) { 983 function clean_term_cache($ids, $taxonomy = '') { 984 global $wpdb; 985 985 986 if ( !is_array($ids) ) 986 987 $ids = array($ids); 987 988 988 foreach ( $ids as $id ) { 989 wp_cache_delete($id, $taxonomy); 990 } 991 992 wp_cache_delete('all_ids', $taxonomy); 993 wp_cache_delete('get', $taxonomy); 994 delete_option("{$taxonomy}_children"); 989 $taxonomies = array(); 990 // If no taxonomy, assume tt_ids. 991 if ( empty($taxonomy) ) { 992 $tt_ids = implode(', ', $ids); 993 $terms = $wpdb->get_results("SELECT term_id, taxonomy FROM $wpdb->term_taxonomy WHERE term_taxonomy_id IN ($tt_ids)"); 994 foreach ( (array) $terms as $term ) { 995 $taxonomies[] = $term->taxonomy; 996 wp_cache_delete($term->term_id, $term->taxonomy); 997 } 998 $taxonomies = array_unique($taxonomies); 999 } else { 1000 foreach ( $ids as $id ) { 1001 wp_cache_delete($id, $taxonomy); 1002 } 1003 $taxonomies = array($taxonomy); 1004 } 1005 1006 foreach ( $taxonomies as $taxonomy ) { 1007 wp_cache_delete('all_ids', $taxonomy); 1008 wp_cache_delete('get', $taxonomy); 1009 delete_option("{$taxonomy}_children"); 1010 } 1011 995 1012 wp_cache_delete('get_terms', 'terms'); 996 1013 }
Note: See TracChangeset
for help on using the changeset viewer.