[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
Sun Sep 14 13:41:58 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: Core | Version:
Severity: major | Keywords:
--------------------------+-----------------------------
I think I’ve found a bug in the BP_Groups_Group::get() function when
performing meta_query with OR relationship.
Currently I have 4 groups to test with. Each group is assigned a meta_key
=> group_sport with values “running”, “swimming”, “mountain”, “winter”
respectively. When I perform this:
{{{
$meta_query = array(
'relation' => 'OR',
array(
"key" => "group_sport",
"value" => 'mountain',
"compare" => 'LIKE'
),
array(
"key" => "group_sport",
"value" => 'running',
"compare" => 'LIKE'
));
$group_arr = BP_Groups_Group::get(array(
'per_page'=>-1,
'meta_query' => $meta_query
));
}}}
it retrieves mountain and running but also incorrectly retrieves swimming
and winter.
On further investigation I noticed that table joins in
BP_Groups_Group::get() and get_meta_query_sql() are done using commas
rather than INNER JOIN, etc. I changed the functions to use INNER JOIN
instead and it now works correctly on my test site. Can anyone else
confirm this bug please? I'm running WP 4.0 and BP 2.0.2.
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5874>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list