Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/07/2013 01:31:27 AM (13 years ago)
Author:
boonebgorges
Message:

Improvements to refreshing of total_group_count on group membership events

When group membership status is changed for a user, that user's
total_group_count meta must be updated. This changeset introduces a number of
improvements to the way this updating is done:

  • Update using an actual queried group count, rather than incrementing. This ensures that even if the count is off (due to a bug in BP or some other plugin), it will be corrected the next time a membership event is recorded.
  • Move the total_group_count refreshing further down the stack. Previously, the updating was happening at various depths: sometimes in the bp-groups-functions.php functions, sometimes in the database methods, and sometimes not at all. By moving the updates so that they directly follow the database queries, we reduce redundancy and ensure that the group count is updated in all cases

This changeset also introduces integration tests for the relevant groups_*
membership functions and total_group_count.

Fixes #5018

Props mukkundthanki, r-a-y for early patches

File:
1 edited

Legend:

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

    r7172 r7179  
    302302    // Modify group member count
    303303    groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') - 1 );
    304 
    305     // Modify user's group memberhip count
    306     bp_update_user_meta( $user_id, 'total_group_count', (int) bp_get_user_meta( $user_id, 'total_group_count', true ) - 1 );
    307304
    308305    /**
Note: See TracChangeset for help on using the changeset viewer.