WordPress.org

Make WordPress Core

Changeset 5815


Ignore:
Timestamp:
07/21/2007 09:52:35 PM (13 years ago)
Author:
ryan
Message:

Recalculate counts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/upgrade.php

    r5814 r5815  
    671671    }
    672672
    673     //  TODO: Recalculate all counts
     673    // Recalculate all counts
     674    $terms = $wpdb->get_col("SELECT term_taxonomy_id FROM $wpdb->term_taxonomy");
     675    foreach ( (array) $terms as $term ) {
     676        $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = '$term'");
     677        $wpdb->query("UPDATE $wpdb->term_taxonomy SET count = '$count' WHERE term_taxonomy_id = '$term'");
     678    }
    674679}
    675680
Note: See TracChangeset for help on using the changeset viewer.