Make WordPress Core

Opened 3 years ago

Last modified 15 months ago

#19372 new enhancement

Don't call wp_count_comments() when we don't need to

Reported by: johnbillion Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version: 3.2
Component: Comments Keywords: has-patch
Focuses: performance Cc:


Comments get counted on every admin screen with wp_count_comments(). We can skip a database call by not counting them if the user doesn't have the edit_posts capability.

Side note: With a persistent object cache it's possible to have admin screens with zero database queries with this patch applied. As an exercise you could write a database class that lazy loads MySQL and you'll get an admin screen that doesn't load MySQL. Almost completely pointless, but interesting nonetheless.

Attachments (1)

19372.patch (753 bytes) - added by johnbillion 3 years ago.

Download all attachments as: .zip

Change History (5)

@johnbillion3 years ago

comment:1 @johnbillion3 years ago

  • Keywords has-patch added


comment:2 @scribu3 years ago

I think 'moderate_comments' would be a more appropriate capability to check. Related: #12104

comment:3 @ocean903 years ago

Related: #11409, #14751

Last edited 3 years ago by ocean90 (previous) (diff)

comment:4 @nacin15 months ago

  • Component changed from Performance to Comments
  • Focuses performance added
Note: See TracTickets for help on using tickets.