[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 13:42:36 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:  Awaiting Review
Component:  Groups        |     Version:
 Severity:  major         |  Resolution:
 Keywords:                |
--------------------------+------------------------------

Comment (by richtelford):

 What I'm saying is that maybe the comma syntax (which I try and steer
 clear of) is the cause of the problem. The solution would be to replace
 the comma syntax with the correct relevant JOINs (as I have done). Comma
 syntax can result in ambiguous JOINs and is reflected by the incorrect
 results I'm getting.

 Perhaps you need a unit test for different meta_value but using the same
 key?

 {{{
 $meta_query[] = array(
         "key" => "samekey",
         "value" => 'value1',
         "compare" => 'LIKE'
 );

 $meta_query[] = array(
         "key" => "samekey",
         "value" => 'value2',
         "compare" => 'LIKE'
 );

 if(count($meta_query) > 1)
 {
         $meta_query = array_merge(array('relation' => 'OR'), $meta_query);
 }

 $group_result = BP_Groups_Group::get(array(
         'per_page'=>-1,
         'meta_query' => $meta_query
 ));
 }}}

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


More information about the buddypress-trac mailing list