Bug #2086
closedGroups > Invitations reads "No Pending Invites" even when there are
0%
Description
From a user report:
When I go to "My Groups" Menu under "My Commons" - it says "No Pending Invites".
However, when I click on "No Pending Invites" sure enough there is an invitation from the [x] Group.
I accepted the invitation and now have access to the Group.
Haven't verified.
Files
Updated by Dominic Giglio about 12 years ago
- Target version changed from 1.4.7 to 1.4.8
Updated by Dominic Giglio about 12 years ago
- Target version changed from 1.4.8 to 1.4.9
Updated by Dominic Giglio about 12 years ago
Boone,
I believe I've found a small bug in the BP core that's causing this issue.
Here's what this issue boils down to:
The "My Groups" item in the "My Commons" menu is created by the setup_admin_bar()
function starting on line 487 of bp-groups-loader.php
. It calls groups_get_invites_for_user()
from line 557 of bp-groups-functions.php
. That function returns the result of calling the static method BP_Groups_Member::get_invites()
from line 1024 of bp-groups-classes.php
. That return value is an associative array with two keys: 'groups' and 'total'. It's the latter that's being checked and used in setup_admin_bar()
. But it's using '->' notation instead of '[]' like it's a stdObject. As soon as I changed it from $count->total
to $count['total']
the menu correctly displayed the proper number of pending invites. (screenshot attached)
I say I "believe" that I've found a bug in core because this seems like an incredibly obvious bug and I can't believe it hasn't been caught yet. Let me know what you think and if I should open a Trac ticket for the community to investigate.
Updated by Boone Gorges about 12 years ago
- Status changed from Assigned to Resolved
Good catch. Looks like this had already been fixed for trunk. I've backported the fix to the 1.6 branch. https://buddypress.trac.wordpress.org/ticket/4417
https://buddypress.trac.wordpress.org/changeset/6481
Applied to CAC in https://github.com/castiron/cac/commit/8a3ec8a58993b8f3322b77bf5e9792bfe2d63a81
Updated by Dominic Giglio about 12 years ago
Awesome, but you missed one small spot in our repo.
Line 505 of bp-groups-loader.php:
if ( !empty( $count->total ) )
Has to be changed as well or that if() will never be true.