[wp-trac] [WordPress Trac] #43212: In WP Posts List Table class, comment_pending_count is calculated even if post_type does not support comments

WordPress Trac noreply at wordpress.org
Fri Feb 2 02:41:44 UTC 2018


#43212: In WP Posts List Table class, comment_pending_count is calculated even if
post_type does not support comments
-------------------------------+-----------------------------
 Reporter:  seanchayes         |      Owner:
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:  trunk
 Severity:  normal             |   Keywords:
  Focuses:  administration     |
-------------------------------+-----------------------------
 When viewing a list of Posts or `post_type`'s in WP Admin the WP Posts
 List Table class always calculates the `get_pending_comments_num()`
 without checking if the post type being listed has 'comments' support.
 This generates an unnecessary and unused query to the database.

 I propose adding a `post_type_supports` check at this time to see if the
 post type support comments. If it does then calculate the pending comments
 num and if it does not then skip over the `get_pending_comments_num()`
 function call and do not calculate the pending comments num.

 I have put together a patch that addresses this issue and will attach it
 to this ticket.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/43212>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list