[wp-trac] [WordPress Trac] #16603: Add hooks to wp_count_posts()

WordPress Trac wp-trac at lists.automattic.com
Tue Sep 25 08:50:18 UTC 2012


#16603: Add hooks to wp_count_posts()
--------------------------+------------------
 Reporter:  mikeschinkel  |       Owner:
     Type:  enhancement   |      Status:  new
 Priority:  normal        |   Milestone:  3.5
Component:  Query         |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |
--------------------------+------------------

Comment (by nacin):

 Filters should occur outside caching. (Otherwise we end up #7213 and
 [8225] which results in #21267, not to mention many other side effects.)

 [attachment:count-posts_3.2.patch] looks good. I'd suggest we rename a
 bunch of variables in that function so both filters receive $counts,
 rather than the dubious $count and $stats variables, and it is clear what
 is going on.

 If there is truly a desire to alter the query directly, then a pre_*
 filter should be added. I don't think that is particularly necessary.

 A side note, the counts cache bucket is non-persistent, which means a
 persistent cache won't eliminate the query. The counts cache bucket is
 used for things that are annoying to invalidate or would be invalidated
 constantly, but is still good to hold onto for the pageload.

 Also, unrelated, that wp_cache_set() should technically be a
 wp_cache_add().

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16603#comment:8>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list