[buddypress-trac] [BuddyPress Trac] #7677: Group with no admin or mod causes heavy user query

buddypress-trac noreply at wordpress.org
Tue Jan 30 18:03:56 UTC 2018


#7677: Group with no admin or mod causes heavy user query
--------------------------+-----------------------------
 Reporter:  cyclic        |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Core          |    Version:
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 As mentioned in
 https://wordpress.slack.com/archives/C02RQBYUG/p1517333350000551

 When a BP group has no admins or mods,
 BP_Groups_Group->set_up_admins_and_mods() runs a user query with an empty
 array for 'include' which ends up fetching all users instead of none. This
 negatively affects performance up to and including memory exhaustion fatal
 errors on sites with lots of users (I see extra memory usage of roughly
 300MB on a site with 12000 users).

 This is the line that runs the query:
 https://github.com/buddypress/BuddyPress/blob/master/src/bp-groups/classes
 /class-bp-groups-group.php#L563

 Pasted here in case that link goes stale:
 {{{#!php
 $admin_mod_users = get_users( array(
         'include' => array_merge( $admin_ids_plucked, $mod_ids_plucked ),
         'blog_id' => null,
 ) );
 }}}

 I'm interested in implementing a patch for this. Something like this?

 {{{#!php
 $admin_mod_ids = array_merge( $admin_ids_plucked, $mod_ids_plucked );
 $admin_mod_users = [];

 if ( ! empty( $admin_mod_ids ) ) {
         $admin_mod_users = get_users( array(
                 'include' => $admin_mod_ids,
                 'blog_id' => null,
         ) );
 }
 }}}

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7677>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list