Make WordPress Core

Opened 13 years ago

Last modified 6 years ago

#18385 new enhancement

Canonical redirections not suited for Queries with multiple query vars and "pretty permalinks" in general

Reported by: dd32's profile dd32 Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.2
Component: Canonical Keywords: dev-feedback has-patch needs-refresh
Focuses: Cc:

Description

When the Canonical code was originally written, it served it's purpose quite well. However, over the years the number of Query vars which can be used to access content via has increased, and so have the number of archive views. This has lead to increased complexity in the Taxonomy canonical code which has needlessly caused bugs.

What I'm proposing, is that it might be time to lay to rest the current if.. elseif.. elseif.. style checks, It's not possible for 1 if branch to handle every single access point without duplicating another branch.

As a result, I've put a half-finished together alternate version of Canonical, It's based on tallying up which query vars have been used/accounted for and removing any duplicates.. It's certainly not the best, but it's fairing better with the unit tests so far.

Unit Testing: http://unit-tests.trac.wordpress.org/browser/wp-testcase/test_includes_canonical.php
Before: FF.......FFFF..FFF.....F......FFFFFF.F....F.....FF....FF...
 After: FF...........FFF..................FF..................F....

It's a work in progress, but it's worth considering IMO.

Attaching a diff, and the full file (since the diff is going to be rather unreadable in some sections)

Attachments (2)

canonical.php (19.7 KB) - added by dd32 13 years ago.
18385.patch (17.6 KB) - added by dd32 13 years ago.

Download all attachments as: .zip

Change History (6)

@dd32
13 years ago

@dd32
13 years ago

#1 @dd32
13 years ago

The approach taken in that alteration is to continue using the if branching, but taking note of what query parameters which can be removed with that url(ie. which ones the Path part of the url will take care of - the Rewrite), and ensuring that only those are removed, retaining all other params via $_GET.

It has a few failings still, and a few regressions (can't handle custom rewrite rules at all in it's present form) and is a rather hack job..

#2 @scribu
13 years ago

  • Cc scribu added

#3 @chriscct7
10 years ago

  • Keywords has-patch added

#4 @chriscct7
9 years ago

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