Recalculate counts

git-svn-id: https://develop.svn.wordpress.org/trunk@5815 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2007-07-21 21:52:35 +00:00
parent e98062fb93
commit 9919fa4f39
1 changed files with 6 additions and 1 deletions

View File

@ -670,7 +670,12 @@ function upgrade_230() {
$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'linkcategories');
}
// TODO: Recalculate all counts
// Recalculate all counts
$terms = $wpdb->get_col("SELECT term_taxonomy_id FROM $wpdb->term_taxonomy");
foreach ( (array) $terms as $term ) {
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = '$term'");
$wpdb->query("UPDATE $wpdb->term_taxonomy SET count = '$count' WHERE term_taxonomy_id = '$term'");
}
}
function upgrade_old_slugs() {