[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 11:22:40 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):

 Just tested on a fresh install and problem persists. To replicate I
 created 4 groups within wp-admin and then manually added unique meta data
 for each group to wp_bp_groups_groupmeta. Then to quickly test I added the
 following to the top of /wp-content/buddypress/bp-templates/bp-
 legacy/buddypress/groups/index.php:


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

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


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

 print_r($meta_query);

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


 print_r($group_result);
 }}}

 This returns all 4 groups instead of the 2 I was expecting.

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


More information about the buddypress-trac mailing list