#9000 closed defect (bug) (fixed)
Group member object cache not refreshed after removal
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 12.0.0 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Groups | Keywords: | has-patch commit |
| Cc: |
Description
If you're using memcached and remove a member from a group, the corresponding cached value isn't cleared in all of the places where it's fetched.
Environment setup
- Core
trunk@89da2ff3a9 - BuddyPress
11.3.1 - memcached plugin. No other plugins active.
- twentytwentythree theme
- memcached server
- memcache (no
d) PHP extension - Create a group with ID
1 - Create a user with ID
2
Reproduce bug
wp bp group member list 1. Only shows user1. User2is not listedwp bp group list --user-id=2. Shows no memberships
wp bp group member add --group-id=1 --user-id=2. Shows successwp bp group list --user-id=2. Shows the membership is assignedwp bp group member list 1. User2is listed
wp bp group member remove --group-id=1 --user-id=2. Shows success.wp bp group member list 1. User2not listedwp bp group list --user-id=2
group member list is correct, but group list --user-id still has the cached value from before the removal. If you check the wp_bp_groups_members table, you'll see that the membership was removed.
- Run
flush_allin memcached telnet wp bp group list --user-id=2
Now it correctly shows no memberships.
If you disable the memcached plugin and repeat steps, you'll get the correct results. So the bug is limited to memcached.
I encountered this when debugging some web code, so it's not limited to the WP-CLI commands, I just used those above to make reproduction simpler.
Attachments (1)
Change History (9)
This ticket was mentioned in PR #171 on buddypress/buddypress by @iandunn.
2 years ago
#1
- Keywords has-patch added
#2
@
2 years ago
- Milestone changed from Awaiting Review to 12.0.0
Hello @iandunn ☺️,
Thanks a lot for your report and patch 👍. Patch looks great. I’ll look at it more deeply asap.
#3
@
2 years ago
This is really weird, according to unit tests cache seems to be cleared.
If this is specific to memcached, could you also test when a member leaves the group ? I'm afraid as the fired hook in this case is different groups_leave_group() or BP_Groups_Member::delete() might also miss clearing memcached cache.
@espellcaste is the "leave" command missing in https://github.com/buddypress/wp-cli-buddypress/blob/master/src/group-member.php ?
#4
@
2 years ago
I didn't spend much time testing transients, but when I did I wasn't able to reproduce it. I could only reproduce it while using memcache.
Thanks for pointing out those additional cases, I'll test them 👍🏻
#5
@
2 years ago
It looks like memcache does gets cleared from groups_leave_group() 👍🏻 I'm guessing by this:
#6
@
2 years ago
- Keywords commit added
Thanks a lot for your checks @iandunn I'll commit the PR asap 👍
The
groups_remove_memberaction triggersgroups_clear_group_user_object_cache(),but that doesn't clear the cache set inBP_Groups_Group::get().An extra action was added to reset the
bp_groupscache incrementor when a member is removed.