[wp-hackers] Does the term_taxonomy count get updated for future posts?

Callum Macdonald lists.automattic.com at callum-macdonald.com
Mon Apr 14 09:41:51 GMT 2008


G'day,

It appears that the wp_update_term_count() function is only called 
within the wp_delete_object_term_relationships() and 
wp_set_object_terms() functions. For the post_tag and category 
taxonomies, the _update_post_term_count() function is called to update 
the count.

This function uses the following SQL query:
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';

This query only counts terms which are applied to published posts. 
Therefore, it does not count any terms where the post_status is future. 
That makes sense.

However, I can't find anywhere when the wp_update_term_count() function 
is called when a post is transitioned from future to publish status. So, 
in theory, if a user published a whole bunch of future posts and then 
didn't post anything else, the term_counts would never be updated.

I'm pretty sure this is correct, and therefore a bug, but I'm not 
absolutely 100% confident, so I haven't filed it in trac yet. Can anyone 
confirm if this is correct, or if in fact I've missed something?

Cheers - Callum.



More information about the wp-hackers mailing list