#8752 closed defect (bug) (invalid)
get_permalink() bug
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Priority: | low | |
Severity: | trivial | Version: | 2.7 |
Component: | Permalinks | Keywords: | |
Focuses: | Cc: |
Description
I presume this bug has been around for quite a while...
If you define WP_HOME in the wp-config file to, say, http://localhost/blah/
then permalinks end up like:
http://localhost/blah//structure
The issue is the way they're defined in the get_permalink() function:
$permalink = get_option('home') . str_replace($rewritecode, $rewritereplace, $permalink);
this should be:
$permalink = rtrim(get_option('home'), '/') . '/', ltrim(str_replace($rewritecode, $rewritereplace, $permalink), '/');
no?
Change History (10)
#2
@
15 years ago
oh, and the trailing slash is important on http://localhost/blah/ to reproduce.
#3
@
15 years ago
along the same lines, the wp-login.php link becomes completely broken:
http://localhost//wp-login.php?redirect_to=http%3A%2F%2Flocalhost%2Fwp-admin%2F
this essentially forbids any login, presumably due to the cookie path. surely there is something wrong in there.
#4
@
15 years ago
- Component changed from General to Permalinks
- Keywords needs-patch added
- Owner changed from anonymous to ryan
- Severity changed from major to normal
Surely the issue at fault here, Is that its being defined in the first place with a trailing slash? in which case, people need to read the docs more closely before defining it, Its exactly the same in the admin panel i believe.
eitherway, an untrailingslashit() in the get_option override filter should work well..
#5
@
15 years ago
Btw, I initially ran into the bug when I tried adding a filter to option_home.
add_filter('option_home', 'user_trailingslashit', 30);
It seemed to make more sense that way, since http://www.domain.com gets redirected by the canonical url stuff to http://www.domain.com/ when the permalink structure has a trailing /.
#7
@
15 years ago
or then, the _config_wp_home() and _config_wp_siteurl() functions should be documented in such a way that users don't try to add a trailing slash.
#8
@
15 years ago
Denis-de-Bernardy:
You don't need anyone's permission to create a patch. _config_wp_home() and _config_wp_siteurl() are basically private functions to WordPress, so I'm unsure what documenting them to include what you say would help. The documentation you are talking about should be located where it seems most logical.
#9
@
15 years ago
- Keywords needs-patch removed
- Priority changed from normal to low
- Resolution set to invalid
- Severity changed from normal to trivial
- Status changed from new to closed
I think we can close this one as invalid.
I bumped into a separate, double-slash bug on a customer's site. It seemed related to his using a /category/postname.htm structure. Some posts would then get a double-slash for no obvious reason. But I failed to reproduce it on my end. (I'll open a new ticket if I run into it again.)
$permalink = rtrim(get_option('home'), '/') . '/' . ltrim(str_replace($rewritecode, $rewritereplace, $permalink), '/');
even... but you probably got the point.