[buddypress-trac] [BuddyPress Trac] #7149: Templates: locating empty array of template(s) errors undefined variable

buddypress-trac noreply at wordpress.org
Tue Jun 28 20:52:28 UTC 2016


#7149: Templates: locating empty array of template(s) errors undefined variable
--------------------------+-----------------------------
 Reporter:  Offereins     |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Templates     |    Version:
 Severity:  normal        |   Keywords:  has-patch
--------------------------+-----------------------------
 In order to prevent loading a specific template part, in my case the
 'activity/post-form' (a brilliant thought of mine to make the activity
 stream contain only actual site activity), I empty the array of templates
 to locate through filtering `bp_get_template_part`.

 Thus follows sending an empty array into `bp_locate_template()`. However,
 here the array will be looped, creating new variables in the loop that do
 not exist outside of it. Beyond the loop these variables (`$template_name`
 being the first) are then used, but since the loop was never run, the
 variable appears to be undefined.

 What I expect is that the template loading dies silently when there appear
 to be no templates requested.

 To fix this, I suggest to only run `bp_locate_template()` when the list of
 templates is non-empty. Patch is attached.

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


More information about the buddypress-trac mailing list