The bp_rewrites_get_url() function causing 404 errors #307
emaralive
started this conversation in
Coding Related
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Note
This is a placeholder for further analysis and actions to be taken. At the moment, I'm just front loading some of the information and will update this discussion when I have more available time.
Due to the way the
bp_rewrites_get_url()
1 is currently coded there is the potential for 404 errors when the permalink structure is missing a trailing slash. For example, the following support topics give indication of such behavior:Using BuddyPress 14.3.4 as reference line 273 of the
bp_rewrites_get_url()
function contains theuser_trailingslashit()
function which will conditionally add or remove the trailing slash depending on the permalink structure. This, in and of itself, appears to be problematic due to the potential to concatenate a URL that will result in a 404 error.Content taken from a reply to the Problem / in Permalinks topic
Apparently, this is the current behavior of the
bp_rewrites_get_url()
function, i.e., the missing trailing slash, when the permalink structure is missing a trailing slash. Hence, a permalink of/%postname%/.html
will result in a URL with a missing trailing slash, e.g.:site.url/members/<user_name>
This causes a 404 error when bbPress tries to concatenate the URLs for the following:
What’s peculiar is that “Topics Started” isn’t affected because, for bbPress, all member area URLs (navigation links) are based on either the
bp_displayed_user_domain()
or thebp_loggedin_user_domain()
functions and both of these functions have thebp_rewrites_get_url()
function in the chain for return.Regardless, this appears to be problematic due to some 3rd party themes and plugins that make use of various other BP functions that have
bp_rewrites_get_url()
function in the chain for return.As an example to reach the "Replies Created" page the nav link should be (reference: Problem / in Permalinks forum topic):
site.url/members/<user_name>/forums/replies
However, the nav link is:
site.url/members/<user_name>forums/replies
- notice the missing slash between "user_name" and "forums"Screenshot of Forum page in member area
I'm not sure why the coding was written as such, i.e., remove the trailing slash if the permalink structure is missage a trailing slash, the documentation that describes the
bp_rewrites_get_url()
makes no reference to the "missing slash" behavior, that is, unless I overlooked a reference to such.Steps to Reproduce
Perhaps, the simplest example for steps to reproduce is to install/activate the Buddyx Theme:
%postname%/.html
as a custom permalink structureTip
Another method is to set the permalink structure to
Numeric
, the default is/archives/%post_id%
.Screenshot of the results for the Buddyx theme example
The Buddyx theme constructs the notification icon link as:
bp_loggedin_user_domain() . $bp->notifications->slug
The
bp_loggedin_user_domain()
function returns a URL without the trailing slash and thus when$bp->notifications->slug
is concatenated, the complete URL is erroneous and a 404 error is the result when the link is clicked.Additional information will be added if warranted and when time is available to do so. For now, this should be enough information in which to engage in conversation.
Can of Worms
Note
The extent of the anomaly and where the issue(s) reside(s) is unknown at this time. This is just a placeholder to remind myself to dig deeper and provide additional detail in support of the following description.
Setting the permalink structure to
Plain
creates a number of issues with the URL structure which again nets a 404 error or a redirect to an unintended real page, e.g., clicking theManage
link within a Group redirects to the Groups directory page. Additionally, this causes unexpected results for bbPress navigation and appears to have the same consequences for other plugins, as well.Analysis
For the Groups
manage
link the redirect to the Group directory page is caused by the&
(ampersand) character being converted to its HTML entity equivalent, e.g.,&
which happens when the URL is run through thewp_filter_kses()
function when thebp_get_group_url()
function is called. Options to fix are:sanitize_url()
function or something similar.html_entity_decode()
function after the URL through thewp_filter_kses()
function.For the bbPress issue, at the moment, it appears to involve the way the URLs are currently constructed.
Footnotes
Footnotes
Introduced in BuddyPress 12.0.0 ↩
Beta Was this translation helpful? Give feedback.
All reactions