Make WordPress Core

Opened 12 years ago

Closed 11 years ago

#31081 closed enhancement (fixed)

Prime the comments cache in get_comments() rather than in comment_template()

Reported by: dd32 Owned by: rachelbaker
Priority: normal Milestone: 4.3
Component: Comments Version:
Severity: normal Keywords: has-patch commit
Cc: Focuses: performance

Description

At present, update_comment_cache() is called within comments_template(), on the result of get_comments().

Unfortunately this means that any plugins which use get_comments() and then use a function which relies upon a comment object, for example, get_comment_author_link( $comment_id ) it'll have a cache-miss and query the DB for data that we could've primed ourselves.

Attachments (2)

31081.diff​ (2.2 KB ) - added by dd32 12 years ago.
31081.2.diff​ (1.0 KB ) - added by rachelbaker 11 years ago.

Download all attachments as: .zip

Change History (4)

#1 @rachelbaker
11 years ago

  • Keywords commit added
  • Milestone Awaiting Review → 4.3
  • Owner set to rachelbaker
  • Status new → accepted
  • Type defect (bug) → enhancement

Refreshed the patch so it applies cleanly. This is a small fix that appears to me to work as intended. Milestoning for 4.3

#2 @nacin
11 years ago

  • Resolution → fixed
  • Status accepted → closed

In 32769:

Update comment caches in WP_Comment_Query, rather than comments template.

props dd32.
fixes #31081.

Note: See TracTickets for help on using tickets.