[buddypress-trac] [BuddyPress Trac] #5824: Groups Meta Query, inconsistent results considering the meta query args
buddypress-trac
noreply at wordpress.org
Wed Aug 20 14:04:25 UTC 2014
#5824: Groups Meta Query, inconsistent results considering the meta query args
--------------------------+-----------------------
Reporter: imath | Owner:
Type: defect (bug) | Status: new
Priority: high | Milestone: 2.1
Component: Groups | Version: 1.8
Severity: normal | Keywords: has-patch
--------------------------+-----------------------
Currently working on a project where i use Group Meta queries. I've
noticed that the '''meta_key''' is not parsed and not returned in the
{{{$sql_array['where']}}} part built in
{{{BP_Groups_group::get_meta_query_sql()}}}
Let's take an example, i want to check if groups have activated a group
extension. The groupmeta could be '_my_group_extension_active' having a
value set to 1 if active, 0 otherwise.
if i user this meta_query to get these groups
{{{
$groups_query['meta_query'] = array(
array(
'key' => '_my_group_extension_active',
'value' => 1,
'compare' => '='
)
);
}}}
Then, it will return all groups that have a meta_value set to 1 '''but
not''' the groups that have a '''meta_key set to
'_my_group_extension_active'''' and a meta_value set to 1. So there's a
big chance if another meta_key has a value set to 1 (for example
total_member_count) that the results are inconsistent.
To make sure meta_key is parsed in
{{{BP_Groups_group::get_meta_query_sql()}}}, i think we need to loop in
the {{{$meta_query_where_clauses}}} to build the {{{$sql_array['where']}}}
part. See attached patch which is working in my case.
It would be great if fixed in 2.1 :)
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5824>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list