Make WordPress Core

Changeset 18999


Ignore:
Timestamp:
10/18/2011 09:01:55 PM (13 years ago)
Author:
ryan
Message:

Call wp_update_term_count() only for those terms that have been added to or removed from the object. Props jeremyclarke. fixes #18631

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/taxonomy.php

    r18995 r18999  
    21182118    $tt_ids = array();
    21192119    $term_ids = array();
     2120    $new_tt_ids = array();
    21202121
    21212122    foreach ( (array) $terms as $term) {
     
    21402141        $wpdb->insert( $wpdb->term_relationships, array( 'object_id' => $object_id, 'term_taxonomy_id' => $tt_id ) );
    21412142        do_action( 'added_term_relationship', $object_id, $tt_id );
    2142     }
    2143 
    2144     wp_update_term_count($tt_ids, $taxonomy);
     2143        $new_tt_ids[] = $tt_id;
     2144    }
     2145
     2146    if ( $new_tt_ids )
     2147        wp_update_term_count( $new_tt_ids, $taxonomy );
    21452148
    21462149    if ( ! $append ) {
Note: See TracChangeset for help on using the changeset viewer.