Skip to:
Content

BuddyPress.org

Changeset 11838


Ignore:
Timestamp:
02/01/2018 08:10:42 PM (4 years ago)
Author:
boonebgorges
Message:

Groups: Admin/mod queries should respect when a group has no admins/mods.

Without this patch, groups without admins or mods can trigger a lookup of
every user on the installation.

Props cyclic.
Fixes #7677.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/classes/class-bp-groups-group.php

    r11805 r11838  
    561561        $mod_ids_plucked = wp_list_pluck( $mod_ids, 'user_id' );
    562562
    563         $admin_mod_users = get_users( array(
    564             'include' => array_merge( $admin_ids_plucked, $mod_ids_plucked ),
    565             'blog_id' => null,
    566         ) );
     563        $admin_mod_ids = array_merge( $admin_ids_plucked, $mod_ids_plucked );
     564        $admin_mod_users = array();
     565
     566        if ( ! empty( $admin_mod_ids ) ) {
     567            $admin_mod_users = get_users( array(
     568                'include' => $admin_mod_ids,
     569                'blog_id' => null,
     570            ) );
     571        }
    567572
    568573        $admin_objects = $mod_objects = array();
  • trunk/tests/phpunit/testcases/groups/class-bp-groups-group.php

    r11762 r11838  
    15171517
    15181518    /**
     1519     * @ticket BP7677
     1520     */
     1521    public function test_demoting_sole_admin() {
     1522        $user = self::factory()->user->create_and_get();
     1523        $group = self::factory()->group->create_and_get( array(
     1524            'creator_id' => $user->ID,
     1525        ) );
     1526        $member = new BP_Groups_Member( $user->ID, $group->id );
     1527        $member->demote();
     1528
     1529        $this->assertEmpty( $group->admins );
     1530        $this->assertEmpty( $group->mods );
     1531    }
     1532
     1533    /**
    15191534     * @ticket BP5451
    15201535     */
Note: See TracChangeset for help on using the changeset viewer.