[wp-trac] [WordPress Trac] #11334: Add caching to get_page_of_comment()

WordPress Trac wp-trac at lists.automattic.com
Sat Dec 5 07:33:50 UTC 2009


#11334: Add caching to get_page_of_comment()
--------------------------+-------------------------------------------------
 Reporter:  Viper007Bond  |       Owner:                         
     Type:  enhancement   |      Status:  new                    
 Priority:  high          |   Milestone:  2.9                    
Component:  Comments      |     Version:  2.9                    
 Severity:  major         |    Keywords:  has-patch needs-testing
--------------------------+-------------------------------------------------
 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.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/11334>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list