[wp-trac] [WordPress Trac] #39242: Add caching to count_user_posts()

WordPress Trac noreply at wordpress.org
Sun Dec 11 23:24:33 UTC 2016


#39242: Add caching to count_user_posts()
-----------------------------+-------------------------------------
 Reporter:  johnjamesjacoby  |      Owner:
     Type:  enhancement      |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Users            |    Version:
 Severity:  normal           |   Keywords:  needs-patch 2nd-opinion
  Focuses:                   |
-----------------------------+-------------------------------------
 The `count_user_posts()` function does not cache the results of its query.

 On the surface, this seems easy enough, but since it accepts multiple
 parameters and intersects with page/post editing, it starts to get complex
 quickly as authors change, posts are transitioned from public to private,
 and custom post types do more elaborate things.

 Since some themes use this directly (Twenty Fourteen, et al) and the REST
 API exposes this data too, there's at least a small win from not hitting
 the database for each and every check.

 Eventually, `count_many_users_posts()` may be able to check for cached
 counts for existing users, and only query for (and prime the caches of)
 users who do not already have cached counts.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39242>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list