Skip to:
Content

BuddyPress.org

Changeset 7275


Ignore:
Timestamp:
07/16/2013 07:31:05 PM (12 years ago)
Author:
boonebgorges
Message:

Fixes total group count for BP_Groups_Group::get() when using meta_query

The fix contained in this changeset is intended to be temporary. A longer-term
fix will mean refactoring the way that total-group queries are composed, so
that the get() method does not have to assemble these queries twice.

See #5099

File:
1 edited

Legend:

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

    r7273 r7275  
    464464        if ( ! empty( $r['user_id'] ) ) {
    465465            $total_sql['where'][] = $wpdb->prepare( "m.group_id = g.id AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0", $r['user_id'] );
     466        }
     467
     468        // Temporary implementation of meta_query for total count
     469        // See #5099
     470        if ( ! empty( $meta_query_sql['where'] ) ) {
     471            // Join the groupmeta table
     472            $total_sql['select'] .= ", {$bp->groups->table_name_groupmeta} gmmq";
     473
     474            // Modify the meta_query clause from paged_sql for our syntax
     475            $meta_query_clause = preg_replace( '/^\s*AND/', '', $meta_query_sql['where'] );
     476            $meta_query_clause = str_replace( $bp->groups->table_name_groupmeta, 'gmmq', $meta_query_clause );
     477            $total_sql['where'][] = $meta_query_clause;
    466478        }
    467479
Note: See TracChangeset for help on using the changeset viewer.