Skip to:
Content

BuddyPress.org

Changeset 9102


Ignore:
Timestamp:
10/29/2014 05:19:09 AM (10 years ago)
Author:
djpaul
Message:

Mentions: don't prime mention results if the site/user has many users/friends.

Sites with huge amounts of users (and therefore probably many potential
friendships) can cause the primed result generation to be slow due to
the number of potential user name lookups/queries made.

Multisite has a function to help us decide if it’s a large network, but
it’s not available for regular WordPress, so we also check the logged
in user’s total friend count. (150 is Dunbar's number.)

In conjunction with the previous commit, this change should help make
the pre-cached result generation more performant.

Fixes #5950. Props imath for original patch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-friends/bp-friends-functions.php

    r9101 r9102  
    580580    }
    581581
     582    // Bail out if the site has a ton of users.
     583    if ( is_multisite() && wp_is_large_network( 'users' ) ) {
     584        return;
     585    }
     586
     587    if ( friends_get_total_friend_count( get_current_user_id() ) > 150 ) {
     588        return;
     589    }
     590
    582591    $friends_query = array(
    583592        'count_total'     => '',                    // Prevents total count
Note: See TracChangeset for help on using the changeset viewer.