Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/09/2021 02:01:40 PM (4 years ago)
Author:
espellcaste
Message:

Improving the group member count routine and the function helper.

The group member count routine was updated to avoid direct, uncached, SQL query and unnecessary cache refresh when a group's Members page was viewed.

is now being used to get the group member count which takes into account users' existence in the site,

the query is now cached and filterable.

was also updated to get the current group from if available.

Props imath
Fixes #7614 and see #6749

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/groups/cache.php

    r11737 r13103  
    260260        $this->assertEquals( $first_query_count, $wpdb->num_queries );
    261261    }
     262
     263    /**
     264     * @group groups_get_total_group_count
     265     * @group counts
     266     */
     267    public function test_total_groups_count() {
     268        $u1 = self::factory()->user->create();
     269        $u2 = self::factory()->user->create();
     270        $u3 = self::factory()->user->create();
     271        self::factory()->group->create( array( 'creator_id' => $u1 ) );
     272        self::factory()->group->create( array( 'creator_id' => $u2 ) );
     273
     274        $this->assertEquals( 2, groups_get_total_group_count() );
     275        $this->assertEquals( 2, BP_Groups_Group::get_total_group_count() );
     276
     277        self::factory()->group->create( array( 'creator_id' => $u3 ) );
     278
     279        $this->assertEquals( 3, groups_get_total_group_count( true ) );
     280        $this->assertEquals( 3, BP_Groups_Group::get_total_group_count() );
     281    }
    262282}
Note: See TracChangeset for help on using the changeset viewer.