#20399 closed defect (bug) (invalid)
WordPress removing multiple dashes/hyphens breaks my permalinks
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.3.1 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description (last modified by )
Recently been trying to upgrade to WordPress 3.3.1 but a lot of our writers use characters like ~ and " in their titles, which am fine with as WordPress has always changed these to dashes. So our URLs have multiple dashes/hyphens.
I have tracked this down to line 892 of /wp-includes/formatting.php which is:
$title = preg_replace('|-+|', '-', $title);
and so it replaces more than 1 consecutive occurance of - with a single -. And this is as the point the code checks the database. Thus a URL e.g. "colin---wiseman---2012" gets changed to "colin-wiseman-2012" which is not a name of a post in the database.
We cannot go back and change all our URLs as there are 1000s of pages and linked to from all around the internet.
The only solution I have found is to comment out this line, but I'd rather there be an option in WordPress that I can flag in the wp-config e.g. define("SANATIZE_DASHES", false); so that the next time I upgrade wordpress there isn't this issue.
I feel that until then, this is a serious bug that could be affecting more blogs than just mine.
Change History (7)
#2
in reply to:
↑ description
@
13 years ago
#3
@
13 years ago
- Resolution set to invalid
- Status changed from new to closed
It appears the version of WordPress I am working with was modified over 2 years ago (maybe by me, but there has been a couple of developers and no code respository). This has caused our issues, but am confused as we have upgraded a couple of times!
Please ignore this now while I go try and fix this! 2272 posts have multiple dashes in them :S
Replying to colinwiseman:
This sounds strange.
That line was added in [774] and exists there since WordPress 1.0.1 "Miles", so under normal circumstances URLs should not contain multiple hyphens.