[buddypress-trac] [BuddyPress Trac] #5824: Groups Meta Query, inconsistent results considering the meta query args
buddypress-trac
noreply at wordpress.org
Wed Aug 20 16:06:04 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 | Resolution:
Keywords: needs-unit-tests |
------------------------------+------------------
Comment (by imath):
This is giving me headache!
ok here the $sql_array returned when using the meta query in my example :
{{{
array(
'join' => 'wp_bp_groups_groupmeta, '
'where' => " AND ( (g.id = wp_bp_groups_groupmeta.group_id AND
CAST(wp_bp_groups_groupmeta.meta_value AS CHAR) = '1') )"
)
}}}
As you can see the where clause is missing the meta_key, my patch was
changing the {{{$sql_array}}} to this :
{{{
array(
'join' => 'wp_bp_groups_groupmeta, '
'where' => " AND ( (g.id = wp_bp_groups_groupmeta.group_id AND
CAST(wp_bp_groups_groupmeta.meta_value AS CHAR) = '1') ) AND (g.id =
wp_bp_groups_groupmeta.group_id AND wp_bp_groups_groupmeta.meta_key =
'_my_group_extension_active' )"
)
}}}
But it's not good as soon as we have more than one meta_query clause and
it duplicates {{{g.id = wp_bp_groups_groupmeta.group_id}}}
I'm testing with 3 groups
- the 3 groups have a _my_group_extension_active meta_key set
- 2 have it set to 1
- 1 have it set to 0
I should have only 2 groups but i have three, because the
total_members_count meta key of last group is 1
So it looks like the group meta query is only looking for a meta_value
instead of looking for a meta_key having a meta_value.
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5824#comment:5>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list