Make WordPress Core

Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#11409 closed enhancement (wontfix)

wp_count_comments() should be cached in a transient.

Reported by: denis-de-bernardy's profile Denis-de-Bernardy Owned by: ryan's profile ryan
Milestone: Priority: normal
Severity: normal Version:
Component: Optimization Keywords: needs-patch
Focuses: Cc:

Description

wp_count_comments() gets called on every admin page. It's not a super expensive on, but it probably belongs in a transient that gets updated whenever the number of pending comment changes.

Attachments (1)

11409.diff (585 bytes) - added by chrisscott 15 years ago.

Download all attachments as: .zip

Change History (12)

#1 @Denis-de-Bernardy
15 years ago

  • Component changed from Cache to Optimization

#2 @Denis-de-Bernardy
15 years ago

  • Keywords needs-patch 2nd-opinion added

#3 @hakre
15 years ago

Nice find, this is for the menu. Maybe we should cache the number of plugins as well or isn't that already chached, right?

#4 @Denis-de-Bernardy
15 years ago

if you're meaning plugin updates, those are already cached.

#5 @nacin
15 years ago

  • Keywords 2nd-opinion removed

@chrisscott
15 years ago

#6 @chrisscott
15 years ago

  • Keywords has-patch added; needs-patch removed

Patch attached against r13330 to change wp_cache_get/set to transient.

#7 follow-up: @nacin
15 years ago

  • Keywords needs-patch added; has-patch removed

We'd also need to update/clear the transient whenever the number of pending comments changes.

#8 in reply to: ↑ 7 ; follow-up: @chrisscott
15 years ago

Replying to nacin:

We'd also need to update/clear the transient whenever the number of pending comments changes.

Sorry, I thought about that and then forgot just as quickly...

This is a little more complex than just pending comment change since the object stored in the transient has counts for total_comments, approved, moderated, spam, trash and post-trash statuses. Not sure how to proceed w/this.

#9 in reply to: ↑ 8 @nacin
15 years ago

Replying to chrisscott:

Replying to nacin:

We'd also need to update/clear the transient whenever the number of pending comments changes.

This is a little more complex than just pending comment change since the object stored in the transient has counts for total_comments, approved, moderated, spam, trash and post-trash statuses. Not sure how to proceed w/this.

We can bust the transient during a comment status change.

#10 @Denis-de-Bernardy
15 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

per discussion on IRC, it's not persistently cached because on sites that get loads of comments, it gets invalidated all the time.

#11 @nacin
15 years ago

  • Milestone 3.0 deleted
Note: See TracTickets for help on using tickets.