Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#20374 closed defect (bug) (fixed)

Unit Test failure: ?pagename=actually-a-post-name redirect

Reported by: markjaquith's profile markjaquith Owned by: markjaquith's profile markjaquith
Milestone: 3.4 Priority: normal
Severity: normal Version:
Component: Canonical Keywords:
Focuses: Cc:

Description

The unit test for canonical redirection of ?pagename=actually-a-post-name is failing.

We find the post, but we're failing to strip the ?pagename=slug part.

Attachments (1)

20374.diff (630 bytes) - added by markjaquith 13 years ago.
strip some common parameters that we do not need if we have an actual URL.

Download all attachments as: .zip

Change History (6)

@markjaquith
13 years ago

strip some common parameters that we do not need if we have an actual URL.

#1 @markjaquith
13 years ago

  • Milestone changed from Future Release to 3.4
  • Owner set to markjaquith
  • Status changed from new to accepted

This is actually pretty nasty in the case of ?name=incomplete-slug, as it will redirect to /2012/04/incomplete-slug-for-post/?name=incomplete-slug and result in a 404.

#2 @markjaquith
13 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In [20380]:

Strip p, page_id, attachment_id, post_type, pagename, and name from redirect query if we get a hit on a 404-guessed permalink. fixes #20374

#3 @markjaquith
13 years ago

In [20386]:

Be a bit more conservative in which args are stripped after redirect_guess_404_permalink().

#4 @nacin
13 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

I think this can break a valid URL to a post. Well, specifically, non-post posts.

get_post_permalink() is used to generate links to items of custom post types. A post type's ugly link is in the form of ?post_type=$post_type&p=1234.

This should be reproducible even with pretty permalinks enabled on the site. Setting public = true, query_var = false, rewrite = false should do it.

#5 @markjaquith
13 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In [20395]:

Better removal of query args in canonical redirects. Only remove them when they are not present in the redirect_url. fixes #20374

Note: See TracTickets for help on using tickets.