Skip to:
Content

BuddyPress.org

Ticket #6940: 6940.02-single-site-check-user-count.patch

File 6940.02-single-site-check-user-count.patch, 1.2 KB (added by r-a-y, 9 years ago)
  • src/bp-blogs/bp-blogs-functions.php

     
    102102
    103103        // Record a single site.
    104104        } else {
    105                 $blog_ids = $wpdb->blogid;
     105                // Count users.
     106                $count = count_users();
     107                $count = $count['total_users'];
     108
     109                /** This filter is documented in /wp-includes/ms-functions.php **/
     110                $is_large_install = apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count );
     111
     112                if ( $is_large_install ) {
     113                        $blog_ids = false;
     114                } else {
     115                        $blog_ids = $wpdb->blogid;
     116                }
    106117        }
    107118
    108119        // Bail if there are no blogs in the network.
     
    133144
    134145                // Get all users.
    135146                $users = get_users( array(
    136                         'blog_id' => $blog_id
     147                        'blog_id' => $blog_id,
     148                        'fields'  => 'ID'
    137149                ) );
    138150
    139151                // Continue on if no users exist for this site (how did this happen?).
     
    142154                }
    143155
    144156                // Loop through users and record their relationship to this blog.
    145                 foreach ( (array) $users as $user ) {
    146                         bp_blogs_add_user_to_blog( $user->ID, false, $blog_id );
     157                foreach ( (array) $users as $user_id ) {
     158                        bp_blogs_add_user_to_blog( $user_id, false, $blog_id );
    147159                }
    148160        }
    149161