Add caching to get_page_of_comment()
|Reported by:||Viper007Bond||Owned by:|
Ack. get_page_of_comment() lacks caching which means if you call get_comment_link() for the same comment ID on the same page multiple times (and outside of the loop), it will query multiple times. You also can't cache the result between page loads (the big "uh oh").
Attached patch introduces a cache that stores comment ID => older comment count (in short, the result of the function's query) on a per-post basis.
When any comment's status is changed, the entire cache for that comment's parent post is deleted as it will likely affect other comments (for example, deleting a comment can change the page of newer comments).
I opted to make a new cache flag (group), but I'm not sure if using an existing one would be better or not.
Oh, and this patch needs through testing and/or a good review.
Change History (18)
comment:10 SergeyBiryukov — 4 months ago
- Keywords needs-refresh removed
- Milestone changed from Future Release to 3.7