Term count fixes

git-svn-id: https://develop.svn.wordpress.org/trunk@5741 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2007-06-21 15:46:49 +00:00
parent fdb786ba7f
commit f63d130503
1 changed files with 2 additions and 4 deletions

View File

@ -472,7 +472,6 @@ function wp_delete_object_term_relationships( $object_id, $taxonomies ) {
$terms = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids');
$in_terms = "'" . implode("', '", $terms) . "'";
$wpdb->query("DELETE FROM $wpdb->term_relationships WHERE object_id = '$object_id' AND term_taxonomy_id IN ($in_terms)");
wp_update_term_count($terms, $taxonomy);
}
@ -701,9 +700,8 @@ function wp_set_object_terms($object_id, $terms, $taxonomy, $append = false) {
if ( ! $append ) {
$delete_terms = array_diff($old_terms, $tt_ids);
if ( $delete_terms ) {
$delete_terms = "'" . implode("', '", $delete_terms) . "'";
$wpdb->query("DELETE FROM $wpdb->term_relationships WHERE term_taxonomy_id IN ($delete_terms)");
$wpdb->query("UPDATE $wpdb->term_taxonomy SET count = count - 1 WHERE term_taxonomy_id IN ($delete_terms)");
$in_delete_terms = "'" . implode("', '", $delete_terms) . "'";
$wpdb->query("DELETE FROM $wpdb->term_relationships WHERE term_taxonomy_id IN ($in_delete_terms)");
wp_update_term_count($delete_terms, $taxonomy);
}
}