Skip to:
Content

BuddyPress.org

Changeset 9230


Ignore:
Timestamp:
12/13/2014 12:43:12 PM (10 years ago)
Author:
boonebgorges
Message:

Don't join against the group members table when fetching total group counts.

The join doesn't take place in the 'paged' count, which leads to inconsistent
query results when groups have no members.

This reverts changes made in [4064].

Props Mamaduka.
Fixes #5584.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-classes.php

    r9131 r9230  
    782782        $paged_groups     = $wpdb->get_results( $paged_groups_sql );
    783783
    784         $total_sql['select'] = "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name} g, {$bp->groups->table_name_members} gm1, {$bp->groups->table_name_groupmeta} gm2";
     784        $total_sql['select'] = "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm";
    785785
    786786        if ( ! empty( $r['user_id'] ) ) {
     
    821821        }
    822822
    823         $total_sql['where'][] = "g.id = gm1.group_id";
    824         $total_sql['where'][] = "g.id = gm2.group_id";
    825         $total_sql['where'][] = "gm2.meta_key = 'last_activity'";
     823        $total_sql['where'][] = "g.id = gm.group_id";
     824        $total_sql['where'][] = "gm.meta_key = 'last_activity'";
    826825
    827826        $t_sql = $total_sql['select'];
Note: See TracChangeset for help on using the changeset viewer.