Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/27/2013 06:09:57 PM (11 years ago)
Author:
boonebgorges
Message:

Enforce DISTINCT in BP_Activity_Activity::get() queries

Previously, we've never really needed to state DISTINCT explicitly in
BP_Activity_Activity::get(), because the kinds of queries we ran would
naturally result in the exclusion of duplicates. The introduction of
the meta_query parameter in 1.8 - and in particular, the ability to
introduce more than one meta_query clause separated by the inclusive
OR relation - uncovered the bug, as single activity items were matching
more than one clause in the meta_query and thus being returned in the
results more than once.

Fixes #5118

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.8/bp-activity/bp-activity-classes.php

    r7228 r7324  
    156156
    157157        // Select conditions
    158         $select_sql = "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name";
     158        $select_sql = "SELECT DISTINCT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name";
    159159
    160160        $from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID";
     
    248248        }
    249249
    250         $total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', "SELECT count(a.id) FROM {$bp->activity->table_name} a {$index_hint_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}", $where_sql, $sort );
     250        $total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', "SELECT count(DISTINCT a.id) FROM {$bp->activity->table_name} a {$index_hint_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}", $where_sql, $sort );
    251251
    252252        $total_activities = $wpdb->get_var( $total_activities_sql );
Note: See TracChangeset for help on using the changeset viewer.