[buddypress-trac] [BuddyPress] #2600: WP pages as component slugs causes redirect problems

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Mon Aug 23 14:53:44 UTC 2010


#2600: WP pages as component slugs causes redirect problems
--------------------------+-------------------------------------------------
 Reporter:  boonebgorges  |       Owner:     
     Type:  defect        |      Status:  new
 Priority:  normal        |   Milestone:  1.3
Component:  Activity      |    Keywords:     
--------------------------+-------------------------------------------------
 In troubleshooting some issues on buddypress.org I came across the
 following issue.

 In 1.3 trunk, you can designate existing WP pages as BP pages. If those WP
 pages are child pages, then the slug of the corresponding activity item is
 a relative link rather than a simple slug. For example, if your blog is at
 http://example.com, and you enter the existing page
 http://example.com/awesome/activity as the Activity home page during the
 BP setup process, $bp->activity->slug will be set as 'awesome/activity'
 instead of 'activity'.

 Usually, this is necessary, especially when "normal" URLs are being
 concatenated with the slug, where by "normal" I mean URLs where the
 component slug comes right after the siteurl (eg
 http://example.com/awesome/members/boonebgorges). But in cases where the
 slug is used in the *middle* of a url, it breaks.

 The example I found is in the Activity component (thus the component of
 this ticket). In the schema described above, activity permalinks (eg
 http://example.com/awesome/activity/p/12345) redirect, via
 bp_activity_action_permalink_router() in bp-activity.php, to
 {{$redirect = bp_core_get_user_domain( $activity->user_id,
 $activity->user_nicename, $activity->user_login ) . $bp->activity->slug .
 '/' . $activity->id . '/';}}
 But that comes out to:
 http://example.com/awesome/members/boonebgorges/awesome/activity/12345
 instead of the correct
 http://example.com/awesome/members/boonebgorges/activity/12345

 There might be other places where this happens, but this is the one I
 found.

 Possible fixes:
 - Hardcode the 'slug' when it appears mid-URL, eg
 {{$redirect = bp_core_get_user_domain( $activity->user_id,
 $activity->user_nicename, $activity->user_login ) .  'activity/' .
 $activity->id . '/';}}. Downside: Doesn't translate
 - Use $bp->activity->name instead. Downside: doesn't translate
 - Refactor the activity permalink catcher to look for the true activity
 slug. In particular, bp_activity.php,
 bp_activity_screen_single_activity_permalink() checks for
 {{      if ( !$bp->displayed_user->id || $bp->current_component !=
 $bp->activity->name )
                 return false;}}
 but maybe it should check for
 {{      if ( !$bp->displayed_user->id || $bp->current_component !=
 $bp->activity->slug )
                 return false;}}
 Downside: Having the word 'awesome' (or whatever it is!) multiple times
 through the URL is a bit strange
 - Create something like $bp->activity->short_slug = BP_ACTIVITY_SLUG, so
 that the slug can remain the same, but the short_slug could be used in
 situations like this.

 (Sorry for the longwindedness, it's a complex problem!)

-- 
Ticket URL: <https://trac.buddypress.org/ticket/2600>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list