Skip to:
Content

BuddyPress.org

Changeset 12741


Ignore:
Timestamp:
10/08/2020 02:31:49 PM (4 years ago)
Author:
dcavins
Message:

Change how groups_get_invites_for_user() reports total.

In groups_get_invites_for_user() use the total returned by the groups_get_groups() call. This helps avoid the edge case where invitations to groups that no longer exist are still recorded in the invitations table. In that case, groups_get_groups() will only return existent groups.

Also update groups_get_invite_count_for_user() to use this more reliable method.

Props imath.

Fixes #8297.

Location:
trunk
Files:
2 edited

Legend:

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

    r12731 r12741  
    14161416        'page'        => $page,
    14171417    );
    1418     $groups = groups_get_groups( $args );
    1419 
    1420     return array( 'groups' => $groups['groups'], 'total' => groups_get_invite_count_for_user( $user_id ) );
     1418
     1419    return groups_get_groups( $args );
    14211420}
    14221421
     
    14341433    }
    14351434
    1436     return count( groups_get_invited_to_group_ids( $user_id ) );
     1435    $invites = groups_get_invites_for_user( $user_id );
     1436    return $invites['total'];
    14371437}
    14381438
  • trunk/tests/phpunit/testcases/groups/class-bp-groups-member.php

    r12431 r12741  
    888888
    889889        $this->assertEqualSets( array( $g1, $g2, $g3 ), wp_list_pluck( $groups['groups'], 'id' ) );
     890        $this->assertEquals( 3, $groups['total'] );
    890891    }
    891892
     
    963964        $groups = groups_get_invites_for_user( $u2, false, false, array( $g2 ) );
    964965        $this->assertEqualSets( array( $g1, $g3 ), wp_list_pluck( $groups['groups'], 'id' ) );
     966        $this->assertEquals( 2, $groups['total'] );
    965967    }
    966968
Note: See TracChangeset for help on using the changeset viewer.