mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-02 05:31:25 +01:00
Fix term count calculation during upgrade. fixes #4922
git-svn-id: http://svn.automattic.com/wordpress/trunk@6051 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8d33c59576
commit
8bbd1008f1
@ -673,10 +673,13 @@ function upgrade_230() {
|
||||
}
|
||||
|
||||
// Recalculate all counts
|
||||
$terms = $wpdb->get_col("SELECT term_taxonomy_id FROM $wpdb->term_taxonomy");
|
||||
$terms = $wpdb->get_results("SELECT term_taxonomy_id, taxonomy 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'");
|
||||
if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) )
|
||||
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = '$term->term_taxonomy_id'");
|
||||
else
|
||||
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = '$term->term_taxonomy_id'");
|
||||
$wpdb->query("UPDATE $wpdb->term_taxonomy SET count = '$count' WHERE term_taxonomy_id = '$term->term_taxonomy_id'");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user