Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/12/2014 09:27:20 PM (10 years ago)
Author:
boonebgorges
Message:

Migrate user 'last_activity' data from usermeta to the activity table

Storing last_activity in usermeta caused severe bottlenecks on sites with
large user bases. The usermeta table has a tendency to get bloated. Its
option_value column is not indexed, and even if it were, it would not be
indexed properly for the kind of chronological sorting that BuddyPress was
using it for.

This changeset refactors all core last_activity user functionality, so that
the data is stored in the wp_bp_activity table (even when the activity
component is disabled).

For backward compatibility with plugins that reference last_activity metadata
entries, all last_activity data is retained in wp_usermeta, and new data will
be mirrored there until further notice.

See #5128

File:
1 edited

Legend:

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

    r7854 r7860  
    362362        }
    363363
     364        // Exclude 'last_activity' items unless the 'action' filter has
     365        // been explicitly set
     366        if ( empty( $filter['object'] ) ) {
     367            $where_conditions[] = "a.type != 'last_activity'";
     368        }
     369
    364370        // Filter the where conditions
    365371        $where_conditions = apply_filters( 'bp_activity_get_where_conditions', $where_conditions, $r, $select_sql, $from_sql, $join_sql );
     
    10631069
    10641070        // split items at the comma
    1065         $items_dirty = explode( ',', $items );
     1071        if ( ! is_array( $items ) ) {
     1072            $items = explode( ',', $items );
     1073        }
    10661074
    10671075        // array of prepared integers or quoted strings
     
    10691077
    10701078        // clean up and format each item
    1071         foreach ( $items_dirty as $item ) {
     1079        foreach ( $items as $item ) {
    10721080            // clean up the string
    10731081            $item = trim( $item );
     
    11211129        if ( !empty( $filter_array['action'] ) ) {
    11221130            $action_sql = BP_Activity_Activity::get_in_operator_sql( 'a.type', $filter_array['action'] );
    1123             if ( !empty( $action_sql ) )
     1131            if ( ! empty( $action_sql ) )
    11241132                $filter_sql[] = $action_sql;
    11251133        }
Note: See TracChangeset for help on using the changeset viewer.