Make WordPress Core

Opened 15 years ago

Closed 15 years ago

Last modified 9 years ago

#8752 closed defect (bug) (invalid)

get_permalink() bug

Reported by: denis-de-bernardy's profile Denis-de-Bernardy Owned by: ryan's profile ryan
Milestone: Priority: low
Severity: trivial Version: 2.7
Component: Permalinks Keywords:
Focuses: Cc:


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:


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), '/');


Change History (10)

#1 @Denis-de-Bernardy
15 years ago

$permalink = rtrim(get_option('home'), '/') . '/' . ltrim(str_replace($rewritecode, $rewritereplace, $permalink), '/');

even... but you probably got the point.

#2 @Denis-de-Bernardy
15 years ago

oh, and the trailing slash is important on http://localhost/blah/ to reproduce.

#3 @Denis-de-Bernardy
15 years ago

along the same lines, the wp-login.php link becomes completely broken:


this essentially forbids any login, presumably due to the cookie path. surely there is something wrong in there.

#4 @DD32
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 @Denis-de-Bernardy
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 gets redirected by the canonical url stuff to when the permalink structure has a trailing /.

#6 @Denis-de-Bernardy
15 years ago

PS: an untrailingslashit() in the overrides makes it work as expected.

#7 @Denis-de-Bernardy
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 @jacobsantos
15 years ago


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 @Denis-de-Bernardy
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.)

#10 @DrewAPicture
9 years ago

  • Milestone 2.7.1 deleted
Note: See TracTickets for help on using tickets.