#7524 closed defect (bug) (fixed)
get_group_administrator_ids() & get_group_moderator_ids() should protect against bad parameter.
| Reported by: | dcavins | Owned by: | dcavins |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.9 |
| Component: | Groups | Version: | 1.6 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | dcavins |
Description
This support thread brought up a problem where bp_group_has_moderators() was generating an error ("PHP Warning: Creating default object from empty value in /wp-content/plugins/buddypress/bp-groups/classes/class-bp-groups-member.php on line 1170"):
https://buddypress.org/support/topic/group-header-file-problems/page/2/#post-265986
My best guess is that what's happening is that bp_group_has_moderators() is being called without a $group parameter, and $groups_template->group isn't set, so the downstream moderator fetching functions are being called without a valid group ID to refer to.
I'm attaching a patch that adds some self-defense in BP_Groups_Member::get_group_administrator_ids() & BP_Groups_Member::get_group_moderator_ids() in the event that the group ID is not set or is otherwise bad.
Sort of related is #3842 in which we try to improve the logic for guessing the current group in all of these template functions that now fall back to $groups_template->group, which of course is only useful in a groups loop.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Protect mod and admin fetchers against bad group IDs.