Make WordPress Core

Opened 10 years ago

Closed 9 years ago

#31081 closed enhancement (fixed)

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

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

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 10 years ago.
31081.2.diff (1.0 KB) - added by rachelbaker 10 years ago.

Download all attachments as: .zip

Change History (4)

@dd32
10 years ago

@rachelbaker
10 years ago

#1 @rachelbaker
10 years ago

  • Keywords commit added
  • Milestone changed from Awaiting Review to 4.3
  • Owner set to rachelbaker
  • Status changed from new to accepted
  • Type changed from defect (bug) to 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
9 years ago

  • Resolution set to fixed
  • Status changed from accepted to 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.