[buddypress-trac] [BuddyPress] #1733: Missing filter on template check inside bp_core_catch_no_access HAS-PATCH

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Sun Jan 31 02:57:07 UTC 2010


#1733: Missing filter on template check inside bp_core_catch_no_access HAS-PATCH
------------------------------------------------------------------------------------+
Reporter:  MrMaz                                                                    |       Owner:     
    Type:  defect                                                                   |      Status:  new
Priority:  critical                                                                 |   Milestone:  1.2
Keywords:  has-patch bp_core_catch_no_access bp_core_catch_uri bp_located_template  |  
------------------------------------------------------------------------------------+

Comment(by rvenable):

 Nice. I noticed this bug breaking my plugin yesterday but didn't have a
 chance to report it, so you beat me to it MrMaz!

 I noticed that the offending code was added in changeset:2088, for what
 its worth.

 I think one problem with the code that in r2088 is that it uses $bp_path
 differently than $bp_path is used in the bp_core_catch_uri() function.
 bp_core_catch_no_access() just appends '.php' to the end of $bp_path and
 trying to locate the template. bp_core_catch_uri() does a little more by
 first treating $bp_path as an array (which doesn't seem to really do
 anything, but might break things later), then trying to locate the
 template but applying filters onto the result (the crucial part for
 plugins).

 So, I think there should be a consistent way of handling $bp_path. You can
 make a function bp_located_template() which handles the locating. That
 function can return the located path, or an empty string if the path
 wasn't found, and a filter can be applied on its return value.

 {{{
 function bp_located_template() {
         /* Can be a single template or an array of templates */
         $templates = $bp_path;

         foreach ( (array)$templates as $template )
                 $filtered_templates[] = $template . '.php';

         return apply_filters( 'bp_located_template', locate_template(
 (array) $filtered_templates, false ), $filtered_templates ) ;
 }

 }}}

 Or better yet, just do everything in bp_catch_uri() and save it as a
 global $bp_located_template instead of $bp_path.

-- 
Ticket URL: <http://trac.buddypress.org/ticket/1733#comment:2>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list