[wp-trac] [WordPress Trac] #5989: Canonical Rewrite Misinterprets Some Queries

WordPress Trac wp-trac at lists.automattic.com
Mon Feb 25 00:23:50 GMT 2008


#5989: Canonical Rewrite Misinterprets Some Queries
----------------------+-----------------------------------------------------
 Reporter:  filosofo  |       Owner:  anonymous                   
     Type:  defect    |      Status:  new                         
 Priority:  normal    |   Milestone:  2.5                         
Component:  General   |     Version:                              
 Severity:  normal    |    Keywords:  canonical-redirect has-patch
----------------------+-----------------------------------------------------
 Here's how to see the problem:
  * Let's say you have a category named "fun" that has category id of 15
  * Let's say you have a post under category "fun" for January 22, 2008
  * Your permalink structure is
 {{{/%category%/%year%/%monthnum%/%day%/%postname%/}}}

 If you request {{{http://www.example.com/fun/2008/01/22/}}} then you get
 (as expected) an archive of all the posts categorized under "fun" on
 January 22, 2008.

 You would expect to get the same thing for
 {{{http://www.example.com/?year=2008&monthnum=1&day=22&cat=15}}}, and if
 you were using default (i.e. no) permalinks, that is what you get with
 that request.  You would also expect canonical redirect to send a request
 for {{{http://www.example.com/?year=2008&monthnum=1&day=22&cat=15}}} to
 {{{http://www.example.com/fun/2008/01/22/}}}.

 Instead, canonical redirect takes
 {{{http://www.example.com/?year=2008&monthnum=1&day=22&cat=15}}}, ignores
 the cat query arg, and redirects to
 {{{http://www.example.com/2008/01/22/}}}

 The general problem is that canonical redirect doesn't do anything with
 the main permalinks setting.  My patch creates a new function,
 {{{get_permalink_from_query}}}, which attempts to generate a permalink
 from the wp_query query vars, using the main permalinks setting.  If it
 can't, it just returns false.

 The patch also has canonical_redirect attempt to use this function first;
 if it fails, it goes on to try the existing permalink-generation methods.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/5989>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list