WordPress.org

Make WordPress Core

Opened 20 months ago

Closed 20 months ago

Last modified 11 months 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
Milestone: 5.1 Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch needs-testing
Focuses: administration Cc:

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 20 months ago.

Download all attachments as: .zip

Change History (5)

@seanchayes
20 months ago

#1 @seanchayes
20 months ago

  • Keywords has-patch needs-testing added

#2 @SergeyBiryukov
20 months ago

  • Milestone changed from Awaiting Review to 5.0

#3 @SergeyBiryukov
20 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to 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
11 months ago

  • Milestone changed from 5.0 to 5.1
  • Version trunk deleted
Note: See TracTickets for help on using tickets.