Make WordPress Core

Opened 13 years ago

Last modified 5 years ago

#17661 new defect (bug)

Appending date & author based query vars to a permalink overrides the permalink

Reported by: dd32's profile dd32 Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Canonical Keywords: needs-testing has-patch needs-unit-tests needs-refresh
Focuses: Cc:


Some canonical code branches are not properly accounting for extra query variables being specified via the url.

For example, these url's are not handled properly:

/2008/?author=1 redirects to /author/admin/
/author/admin/?year=2008 redirects to /year/2008/
/category/uncategorized/?year=2008 redirects to /2008/

This happens with most date based branches, as once a higher priority canonical rule is hit, the permalink component is ignored.

The canonical code includes a branch to add any "forgotten" $_GET variables back onto the url, however this doesn't help when it's the rewritten variables are being lost.

Attachments (3)

fix-canonical-by-matched-query.diff (2.2 KB) - added by wonderboymusic 12 years ago.
17661.diff (2.8 KB) - added by wonderboymusic 11 years ago.
17661-tests.patch (3.4 KB) - added by boonebgorges 10 years ago.
Removing from trunk as per #30284

Download all attachments as: .zip

Change History (7)

#1 @wonderboymusic
12 years ago

  • Keywords needs-testing has-patch added; needs-patch removed

This is probably happening in a million other combinations as well - here's the problem:

1) the flags for is_* are misleading because they are set to true for every present query var, regardless of rewrite structure

2) the redirection happens because redirect_canonical() says "I'm a year! and the year is in the query string when I want pretty permalinks, redirect me!" - it doesn't, however, check if the year is also the matched query or not.

3) /2012/?year=2012 and /?year=2012 should be redirected to /2012/, /{NOT_YEAR}/?year=2012 should not

My patch fixes this for this ticket's use cases - I'm sure there are other cases which could be addressed.

#2 @wonderboymusic
11 years ago

  • Keywords needs-unit-tests added
  • Milestone changed from Future Release to 3.7

#3 @nacin
11 years ago

  • Milestone changed from 3.7 to Future Release

Keywords needs-unit-tests added

10 years ago

Removing from trunk as per #30284

#4 @chriscct7
9 years ago

  • Keywords needs-refresh added
Note: See TracTickets for help on using tickets.