[wp-trac] [WordPress Trac] #13091: edit_post action on wp_update_comment_count_now should not be fired if the comment count hasn't changed

WordPress Trac wp-trac at lists.automattic.com
Fri Apr 23 06:43:15 UTC 2010


#13091: edit_post action on wp_update_comment_count_now should not be fired if the
comment count hasn't changed
--------------------------+-------------------------------------------------
 Reporter:  solarissmoke  |       Owner:     
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  3.0
Component:  Comments      |     Version:  3.0
 Severity:  normal        |    Keywords:     
--------------------------+-------------------------------------------------
 wp_update_comment_count_now() is called whenever a comment status is
 transitioned (or a comment is deleted). However, if the comment transition
 is not from/to the 'approved' status (e.g., if the comment is transitioned
 from 'spam' to 'trash' or from 'unapproved' to 'trash'), then the
 associated post is not actually affected. Therefore in such cases the
 edit_post action shouldn't be fired, because the post has not been
 edited/modified in any way. I would argue that the
 'wp_update_comment_count' action also should not be fired.

 One solution is to check whether the comment count has changed before
 firing the action.  Another possible option is to call
 wp_update_comment_count only when a comment has transitioned in/out of the
 "approved" status. I'm inclined to prefer the former because it involves
 less change.

 Proposed patch to follow.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/13091>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list