[buddypress-trac] [BuddyPress Trac] #7524: get_group_administrator_ids() & get_group_moderator_ids() should protect against bad parameter.

buddypress-trac noreply at wordpress.org
Tue May 16 15:18:34 UTC 2017


#7524: get_group_administrator_ids() & get_group_moderator_ids() should protect
against bad parameter.
--------------------------+-----------------------
 Reporter:  dcavins       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  2.9
Component:  Groups        |    Version:  1.6
 Severity:  normal        |   Keywords:  has-patch
--------------------------+-----------------------
 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.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7524>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list