Opened 9 years ago
Closed 8 years ago
#30018 closed defect (bug) (fixed)
404 error and redirect when using url with query string
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | 4.0 |
Component: | Posts, Post Types | Keywords: | has-patch |
Focuses: | Cc: |
Description
When a query var and the query_var of non-public CPT are the same:
- You will get a 404 error even when the permalink exists.
- redirect_guess_404_permalink() returns the permalink of other post which has slug like {query value}%.
Here an example:
- CPT
foo
has'public' => false
. - The permalink
/a123
exists. - The permalink
/bar/456
exists.
When you visit /a123?foo=4
, You will redirect to other url bar/456?foo=4
and get a 404 error.
I want to get /a123
page and $_GET[ 'foo' ] which is not the CTP query_var
.
I think CTP query_var
parameter must be set to false, if public
parameter is false.
Attachments (3)
Change History (8)
This ticket was mentioned in Slack in #core by jorbin. View the logs.
8 years ago
#3
@
8 years ago
- Keywords has-patch dev-feedback added
- Milestone changed from Awaiting Review to 4.4
30018.diff fixes it. It's in WP::parse_request()
- this seems like a reasonable fix, curious if it would break anything?
#4
@
8 years ago
- Keywords dev-feedback removed
In 30018.2.diff, non-viewable post types shouldn't have their query vars parsed in WP::parse_request()
. Unit test (surprise, surprise) demonstrates this behavior. If you parse their query vars, and the var does not actually exist to represent that item, the request goes 404. The default value for query_var
is true
, which means it will be set to $post_type
if you don't specify something else. register_post_type()
then indiscriminately adds it to WP::public_query_vars
@markjaquith - do you think this is canonical related? Is there a change here that might make sense?