Opened 10 years ago
Last modified 2 months ago
#40032 new defect (bug)
Automatic redirects with _wp_old_slug won't mantain GET parameters if present
| Reported by: | DrLightman | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Permalinks | Version: | 2.1 |
| Severity: | normal | Keywords: | has-patch needs-testing has-unit-tests |
| Cc: | Focuses: |
Description
If for example links come up with GET parameters, for example utm parameters for analytics, they get stripped before the redirect.
post_name = 'new-slug'
_wp_old_slug = 'old-slug'
http://example.org/old-slug/?utm_source=test1&utm_medium=test2&utm_campaign=test3
Wordpress will build the link for the redirect to the new slug without any GET parameter:
I think it should mantein them instead:
http://example.org/new-slug/?utm_source=test1&utm_medium=test2&utm_campaign=test3
I'm not even sure if this should be classified as a bug, if it's the correct behaviour or not. I'll let you judge.
Attachments (3)
Change History (12)
#1
@
10 years ago
- Summary Automatic redirects with _wp_old_slug won't mantein GET parameters if present → Automatic redirects with _wp_old_slug won't mantain GET parameters if present
#5
@
6 years ago
I'll give refreshing @desrosj's patch a go. As old_slug_redirect_url is filterable there is a workaround to add the query parameters with that filter but I think having it fixed in core would be great.
This ticket was mentioned in PR #12633 on WordPress/wordpress-develop by @arkaprabhachowdhury.
3 months ago
#7
- Keywords has-unit-tests added
Trac ticket: https://core.trac.wordpress.org/ticket/40032 | Preserves request query arguments when wp_old_slug_redirect() redirects an old post slug, with focused PHPUnit regression coverage.
#8
@
2 months ago
Test Report
Tested PR #12633 in WordPress Playground.
Steps:
- Renamed a published post slug from hello-world to redirect-target.
- Opened the previous permalink with utm_source=playground and campaign=old-slug-test.
- Confirmed WordPress redirected to redirect-target while retaining both query arguments.
Result:
The patch works as expected. The old-slug redirect preserves non-core query arguments. The attached screenshot shows the prepared Playground post.
#9
@
2 months ago
Opened [PR #12633](https://github.com/WordPress/wordpress-develop/pull/12633) to address this ticket. The PR includes focused regression coverage, and its validation details are recorded in the PR description.
I picked this up because the ticket describes a concrete core behavior or edge case that remains relevant in current WordPress. The proposed change is intentionally scoped to the ticket and is submitted here for code review, with the technical discussion remaining on this ticket.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Preserve
$_GETparams on_wp_old_slugredirects