Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#43212 closed defect (bug) (fixed)

In WP Posts List Table class, comment_pending_count is calculated even if post_type does not support comments

Reported by: seanchayes Owned by: SergeyBiryukov
Priority: normal Milestone: 5.1
Component: Posts, Post Types Version:
Severity: normal Keywords: has-patch needs-testing
Cc: Focuses: administration

Description

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.

Attachments (1)

43212.diff​ (986 bytes ) - added by seanchayes 9 years ago.

Download all attachments as: .zip

Change History (5)

#1 @seanchayes
9 years ago

  • Keywords has-patch needs-testing added

#2 @SergeyBiryukov
9 years ago

  • Milestone Awaiting Review → 5.0

#3 @SergeyBiryukov
9 years ago

  • Owner set to SergeyBiryukov
  • Resolution → fixed
  • Status new → closed

In 42638:

Posts, Post Types: Don't count pending comments in WP_Posts_List_Table::_display_rows() if the post type does not support comments.

Props seanchayes.
Fixes #43212.

#4 @johnbillion
8 years ago

  • Milestone 5.0 → 5.1
  • Version trunk
Note: See TracTickets for help on using tickets.