[wp-trac] [WordPress Trac] #15397: redirect_guess_404_permalink() purposedly doesn't guess posts with updated dates

WordPress Trac wp-trac at lists.automattic.com
Fri Nov 12 00:17:38 UTC 2010


#15397: redirect_guess_404_permalink() purposedly doesn't guess posts with updated
dates
--------------------------+-------------------------------------------------
 Reporter:  archon810     |       Owner:                 
     Type:  defect (bug)  |      Status:  new            
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Canonical     |     Version:                 
 Severity:  normal        |    Keywords:                 
--------------------------+-------------------------------------------------
 '''Problem'''

 Here's my post path scheme: http://site.com/YEAR/MONTH/DAY/SLUG. Whenever
 I have writers working on a post for a while and saving drafts (we're all
 using Windows Live Writer), they oftentimes publish to the date when the
 last draft was saved, i.e. several days in the past. Then, they quickly
 correct the date but the previously tweeted/shared link is now 404 due to
 the changed date.

 I've looked into the source of redirect_guess_404_permalink(), and it
 purposedly narrows down the query when it sees a post date to that date
 only. If I understand correctly, this is done to minimize accidental
 redirects to the wrong post, but has the side effect of not guessing the
 new link if only the date was changed.

 A workaround of removing these lines:
 {{{
   if ( get_query_var('year') )
     $where .= $wpdb->prepare(" AND YEAR(post_date) = %d",
 get_query_var('year'));
   if ( get_query_var('monthnum') )
     $where .= $wpdb->prepare(" AND MONTH(post_date) = %d",
 get_query_var('monthnum'));
   if ( get_query_var('day') )
     $where .= $wpdb->prepare(" AND DAYOFMONTH(post_date) = %d",
 get_query_var('day'));
 }}}

 fixes the problem for me.

 Can this case be solved in the trunk and the code above removed, or logic
 improved? My .htaccess file is filled with 301 redirects to correct wrong
 dates.

 Thank you.

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


More information about the wp-trac mailing list