#3647 closed defect (bug) (fixed)
bp_forum_permalink() is missing a ’/’ (malformed)
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | 1.5.1 | Priority: | normal |
| Severity: | normal | Version: | 1.5 |
| Component: | Forums | Keywords: | |
| Cc: |
Description
Someone posted this on the buddypress forums the other day, but I don't think its been submitted here. Fairly critical bug as users are unable to navigate back to the specific forum from a posted topic.
---
At the top of the group_name/forum/topic/new-topic-in-the-forum/ page
there are two buttons: ? Back to Main Forum Group Forum Directory
But when I click on the Back to main forum button i get a malformed URI
It looks like this:
http://dev.resourceclips.com/groups/jayden-resources-ltdforum//
instead of
http://dev.resourceclips.com/groups/jayden-resources-ltd/forum/
Any ideas?
Thanks in advance
Change History (5)
#2
@
14 years ago
- Component changed from Core to Forums
- Milestone changed from Awaiting Review to 1.5.1
- Severity changed from critical to normal
#3
@
14 years ago
You're right that the link is being created incorrectly. We do need to add the slash.
However, it's worth noting that bp-default, in BP 1.5, does not actually use this function at all (for whatever reason). It'll called in bp-themes/bp-default/forums/single/forum-header.php, which isn't actually called at the moment (the logic in bp_forums_screen_single_topic() never returns true).
Also, trailingslashit() should not be allowing double-slashes. See http://core.trac.wordpress.org/browser/tags/3.2.1/wp-includes/formatting.php#L1170
Further to my post above - I have managed to create a quick fix, but this will need to be submitted to the repository.
Essentially, the permalink wasnt forming properly as it was missing a forward slash before 'forum' on line 1326 of bp-forum-template.php. Also trailingslashit(); was being run twice, which causes two forward-slashes.
My fix is below...
Grimbog
---
function bp_forum_permalink( $forum_id = 0 ) { echo bp_get_forum_permalink( $forum_id ); } function bp_get_forum_permalink( $forum_id = 0 ) { global $bp; if ( bp_is_groups_component() ) { $permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_current_item() . '/' . 'forum' ); } else { if ( empty( $forum_id ) ) { global $topic_template; if ( isset( $topic_template->forum_id ) ) $forum_id = $topic_template->forum_id; } if ( $forum = bp_forums_get_forum( $forum_id ) ) $permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_forums_root_slug() . '/forum/' . $forum->forum_slug ); else return false; } return apply_filters( 'bp_get_forum_permalink', $permalink ); }