Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/30/2014 07:22:59 PM (10 years ago)
Author:
boonebgorges
Message:

When migrating last_activity data, clear all data to avoid duplicates

Previously, duplicates were avoided with a NOT IN subquery. But this caused
load problems on large installations, where the subquery would return
many thousands of results.

Fixes #5572

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-members/bp-members-functions.php

    r8324 r8333  
    10371037    $bp = buddypress();
    10381038
    1039     // The "NOT IN" clause prevents duplicates
     1039    // Wipe out existing last_activity data in the activity table -
     1040    // this helps to prevent duplicates when pulling from the usermeta
     1041    // table
     1042    $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->members->table_name_last_activity} WHERE component = %s AND type = 'last_activity'", $bp->members->id ) );
     1043
    10401044    $sql = "INSERT INTO {$bp->members->table_name_last_activity} (`user_id`, `component`, `type`, `action`, `content`, `primary_link`, `item_id`, `date_recorded` ) (
    10411045          SELECT user_id, '{$bp->members->id}' as component, 'last_activity' as type, '' as action, '' as content, '' as primary_link, 0 as item_id, meta_value AS date_recorded
     
    10431047          WHERE
    10441048            meta_key = 'last_activity'
    1045             AND
    1046             user_id NOT IN (
    1047               SELECT user_id
    1048               FROM {$bp->members->table_name_last_activity}
    1049               WHERE component = '{$bp->members->id}' AND type = 'last_activity'
    1050             )
    10511049    );";
    10521050
Note: See TracChangeset for help on using the changeset viewer.