Opened 17 years ago
Last modified 40 hours ago
#2877 assigned defect (bug)
A Slash too much @ get_pagenum_link()
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.3 | Priority: | normal |
Severity: | normal | Version: | 2.0 |
Component: | Posts, Post Types | Keywords: | has-patch needs-testing has-unit-tests has-testing-info |
Focuses: | template | Cc: |
Description
- File: template-functions-links.php
- Function: get_pagenum_link()
The following code is at the end of the function:
// showing /page/1/ or ?paged=1 is redundant if ( 1 === $pagenum ) { $qstr = str_replace('page/1/', '', $qstr); // for mod_rewrite style $qstr = remove_query_arg('paged', $qstr); // for query style }
If you work with the mod_rewrite style, you will get this URL for the first page:
http://www.example.com/wordpress/index.php/
This wont work (/ at the end).
Correx:
// showing /page/1/ or ?paged=1 is redundant if ( 1 === $pagenum ) { $qstr = str_replace('/page/1/', '', $qstr); // for mod_rewrite style $qstr = remove_query_arg('paged', $qstr); // for query style }
Notes:
- sry for my bad english...
- i've downloaded a german translation of wordpress 2.0.3, so maybe its just in this version... ?!
Attachments (3)
Change History (21)
#2
@
16 years ago
- Resolution set to wontfix
- Status changed from new to closed
No traction in almost a year, so closing as wontfix.
Feel free to re-open it if you have additional information/suggestions/patches/...
#3
@
12 years ago
- Keywords needs-patch added
- Milestone set to Future Release
- Resolution wontfix deleted
- Status changed from closed to reopened
Only enhancements or feature requests can be closed when there's no traction.
#5
@
12 years ago
Note that the problem is with first-page links, not with /page/2, /page/3/ etc.
Original thread: http://wordpress.org/support/topic/plugin-wp-pagenavi-trailing-slash-at-first-page-url-regardless-of-defined-permalink-structure
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
4 months ago
#13
@
4 months ago
- Keywords needs-refresh added
- Owner set to petitphp
- Status changed from reopened to assigned
We discussed this issue during this week Old Tickets Triage Session.
The patch needs to be refreshed. Assigning @petitphp who's willing to add a new patch/unit tests.
Thanks to @SergeyBiryukov, @maigret, @petitphp for discussing this issue :)
This ticket was mentioned in PR #3931 on WordPress/wordpress-develop by @petitphp.
4 months ago
#14
- Keywords has-unit-tests added; needs-refresh removed
Trac ticket: https://core.trac.wordpress.org/ticket/2877
#15
@
4 months ago
PR with refreshed patch added.
I've made a change from the original patch to ensure query_args don't force a trailing slash, and I updated the tests accordingly.
I've tested multiple cases :
- single site install with permalink structure
/%category%/%postname%/
(trailing slash)- link to first page : https://example.com/category/nam-voluptas/
- link to second page : https://example.com/category/nam-voluptas/page/2/
- single site install with permalink structure
/%category%/%postname%
(no trailing slash)- link to first page : https://example.com/category/officiis-incidunt
- link to second page : https://example.com/category/officiis-incidunt/page/2
- multisite subdirectory install with permalink structure
/%category%/%postname%
- link to first page : https://example.com/site-one/category/quia-voluptatem
- link to second page : https://example.com/site-one/category/quia-voluptatem/page/2
- multisite subdomain install with permalink structure
/%category%/%postname%
- link to first page : https://site-one.example.com/category/quasi
- link to second page : https://site-one.example.com/category/quasi/page/2
In every case, get_pagenum_link
correctly matched the permalink structure and only added a trailing slash if present.
This should be ready for testing on more exotic WordPress install.
#16
@
4 months ago
- Milestone changed from Future Release to 6.3
Thanks for the PR @petitphp!
Moving for 6.3 consideration.
No, it's that way in the english version. I don't think that would fix it and there would be a problem with that. Putting the slash in front like you did would make the server redirect to root. So if you have wordpress in a directory it would screw up like so:
You would want this:
http://site.com/wordpress/testing/1/
But you would get this:
http://site.com/testing/1/