WordPress.org

Make WordPress Core

Opened 17 months ago

Last modified 14 months ago

#19903 new enhancement

wp_count_comments() and get_comments_count() both do SQL queries — at Initial Version

Reported by: markjaquith Owned by:
Priority: normal Milestone: Future Release
Component: Comments Version: 3.3.1
Severity: normal Keywords:
Cc:

Description

wp_count_comments() and get_comments_count() are similar functions, with a few differences:

  • Their results are returned in different formats:
    • wp_count_comments() returns an array of:
      • spam
      • approved
      • moderated
      • total_comments
      • trash
      • post-trashed
    • get_comment_count() returns an array of:
      • spam
      • approved
      • awaiting_moderation
      • total_comments
  • wp_count_comments() caches, but get_comment_count() always hits the database.
  • get_comment_count() is used nowhere in WordPress core.

I propose that we add 'trash' and 'post-trashed' reporting to get_comment_count(), and then have wp_count_comments() use get_comment_count() instead of doing its own SQL queries.

See #6884 and #19901

Change History (0)

Note: See TracTickets for help on using tickets.