[wp-trac] [WordPress Trac] #35075: Comment cache ignores custom query vars

WordPress Trac noreply at wordpress.org
Sun Jan 10 17:51:34 UTC 2016


#35075: Comment cache ignores custom query vars
-----------------------------+--------------------------
 Reporter:  jason_the_adams  |       Owner:
     Type:  defect (bug)     |      Status:  new
 Priority:  normal           |   Milestone:  4.5
Component:  Comments         |     Version:  trunk
 Severity:  normal           |  Resolution:
 Keywords:  has-patch        |     Focuses:  performance
-----------------------------+--------------------------

Comment (by jason_the_adams):

 @nacin To be perfectly honest, I'm having a hard time figuring out what
 you mean in relation to the scope of this ticket. It sounds like you're
 talking about the $args as a whole, within the context of the function,
 while this ticket relates ''only'' to the $args as relate to the caching
 of the query. They're not affected for the entirety of the function, but
 only to be serialized and hashed.

 Perhaps some light on how I even stumbled on this will help:

 I'm involved in a project/plugin called [https://piklist.com/ Piklist],
 which attempts to extend WordPress for enterprise-level development. In
 the current beta, support for object (e.g. comments, users, and posts)
 relationships was added. I had finished adding in support for a
 `relate_query` (modeled after meta_query) query_var for these objects, to
 be able to find, for example, posts that belong to another post and user
 (again, just an example).

 I was writing the unit tests for this, and found that my 2nd
 `get_comments` weren't working. After some digging, I realized it was
 because it was caching the result of the first query and giving it back
 for the second. Reason being: the `relate_query` query_var wasn't
 recognized by the caching method. And it would not be at all unrealistic
 for someone to do the following:

 {{{
 #!php
 <?php
 $p1 = get_comments(array(
   'relate_query' => array(
     array(
       'relate' => 'belongs',
       'scope' => 'user',
       'id' => 3
     )
   )
 ));

 $p2= get_comments(array(
   'relate_query' => array(
     array(
       'relate' => 'belongs',
       'scope' => 'user',
       'id' => 4
     )
   )
 ));
 }}}

 This isn't a problem with get_posts and get_users, as they cache
 differently. It's only the comments, terms, and pages that have this
 issue, which also presents inconsistency.

 Hope this helps in better presenting the issue. :)

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35075#comment:20>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list