[buddypress-trac] [BuddyPress Trac] #5874: BP_Groups_Group::get() returns incorrect results when using meta_query with multiple meta_values and OR relationship

buddypress-trac noreply at wordpress.org
Mon Sep 15 16:27:02 UTC 2014


#5874: BP_Groups_Group::get() returns incorrect results when using meta_query with
multiple meta_values and OR relationship
--------------------------+------------------
 Reporter:  richtelford   |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  2.2
Component:  Groups        |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |
--------------------------+------------------
Changes (by boonebgorges):

 * keywords:   => needs-patch
 * severity:  major => normal
 * milestone:  Awaiting Review => 2.2


Comment:

 I've managed to reproduce with a unit test
 (`test_get_with_meta_query_multiple_clauses_relation_or_shared_meta_key_relation_like()`).
 The following conditions have to hold to demonstrate the failure:

 - you have to use relation 'OR'
 - subqueries must share the same 'key'
 - subqueries must use compare 'LIKE' (though this might also happen with
 other compare operators - not sure)

 richtelford - The good news is that, for your current purpose, you should
 just be able to remove the `'compare' => 'LIKE'` lines from your query.
 `WP_Meta_Query` will assume you mean '=', which it seems is what you
 actually do mean here. My tests suggest that this will solve your specific
 problem.

 I have not examined carefully why changing 'compare' breaks things. It's
 possible that it has to do with the fact that the pseudo-ON clauses (`AND
 g.id = gm1.group_id`) are not properly grouped into the bracketed OR
 clauses - though I have no idea why this wouldn't affect '=' clauses.
 Let's have a closer look for 2.2.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5874#comment:16>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list