[buddypress-trac] [BuddyPress Trac] #5170: bp_has_members() in widgets stomps $members_template global

buddypress-trac noreply at wordpress.org
Fri Jan 9 01:39:52 UTC 2015


#5170: bp_has_members() in widgets stomps $members_template global
-----------------------------+------------------------------
 Reporter:  johnjamesjacoby  |       Owner:  johnjamesjacoby
     Type:  defect (bug)     |      Status:  new
 Priority:  high             |   Milestone:  Future Release
Component:  Members          |     Version:  1.0
 Severity:  major            |  Resolution:
 Keywords:  dev-feedback     |
-----------------------------+------------------------------

Comment (by boonebgorges):

 > Is there value is doing this after the widget code is put out? I would
 advocate that it's currently unexpected behavior to have the
 $members_template global populated on any page other than the members
 directory just because there's a widget in a sidebar somewhere.

 In the case of the widgets specifically, I think we can do something like
 this:

 {{{
 global $members_template;

 $old_members_template = null;
 if ( ! empty( $members_template ) ) {
     $old_members_template = clone $members_template;
 }

 if ( bp_has_members() ) {
 // ...
 }

 if ( $old_members_template ) {
     $members_template = $old_members_template;
 } else {
     unset( $GLOBALS['members_template'] );
 }
 }}}

 It's kinda ugly, but it's pretty foolproof. And in the case of widgets, we
 can be confident (as suggested by johnjamesjacoby) that no one is
 expecting global pollution.

 We probably need something more sophisticated for the more general
 problem.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5170#comment:13>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list