### Eclipse Workspace Patch 1.0
#P WPtrunk
Index: wp-includes/default-filters.php
===================================================================
--- wp-includes/default-filters.php	(revision 18885)
+++ wp-includes/default-filters.php	(working copy)
@@ -254,6 +254,7 @@
 add_action( 'publish_post',               '_publish_post_hook',                       5, 1 );
 add_action( 'save_post',                  '_save_post_hook',                          5, 2 );
 add_action( 'transition_post_status',     '_transition_post_status',                  5, 3 );
+add_action( 'transition_post_status',     'wp_recount_term_on_post_transition',      10, 3 );
 add_action( 'comment_form',               'wp_comment_form_unfiltered_html_nonce'          );
 add_action( 'wp_scheduled_delete',        'wp_scheduled_delete'                            );
 add_action( 'admin_init',                 'send_frame_options_header',               10, 0 );
Index: wp-includes/post.php
===================================================================
--- wp-includes/post.php	(revision 18885)
+++ wp-includes/post.php	(working copy)
@@ -2730,13 +2730,7 @@
 	$old_status = $post->post_status;
 	$post->post_status = 'publish';
 	wp_transition_post_status('publish', $old_status, $post);
-
-	// Update counts for the post's terms.
-	foreach ( (array) get_object_taxonomies('post') as $taxonomy ) {
-		$tt_ids = wp_get_object_terms($post_id, $taxonomy, array('fields' => 'tt_ids'));
-		wp_update_term_count($tt_ids, $taxonomy);
-	}
-
+	
 	do_action('edit_post', $post_id, $post);
 	do_action('save_post', $post_id, $post);
 	do_action('wp_insert_post', $post_id, $post);
@@ -2979,6 +2973,28 @@
 	do_action("{$new_status}_{$post->post_type}", $post->ID, $post);
 }
 
+/**
+ * Call update term counter callback for each post transition. (TODO: to improve)
+ *
+ * @since 3.3
+ *
+ * @param string $new_status Transition to this post status.
+ * @param string $old_status Previous post status.
+ * @param object $post Post data.
+ */
+function wp_recount_term_on_post_transition( $new_status, $old_status, $post ) {
+	if ( !apply_filters('recount_term_on_post_transition', true, $new_status, $old_status, $post) ) {
+		return false;
+	}
+	
+	foreach ( (array) get_object_taxonomies( $post->post_type ) as $taxonomy ) {
+		$tt_ids = wp_get_object_terms($post->ID, $taxonomy, array('fields' => 'tt_ids'));
+		wp_update_term_count($tt_ids, $taxonomy);
+	}
+	
+	return true;
+}
+
 //
 // Trackback and ping functions
 //
