WordPress.org

Make WordPress Core

Ticket #13125: 13125-3.patch

File 13125-3.patch, 1003 bytes (added by solarissmoke, 4 years ago)

Don't attempt to redirect to revisions

  • canonical.php

     
    8383        if ( is_404() ) { 
    8484 
    8585                // Redirect ?page_id, ?p=, ?attachment_id= to their respective url's 
    86                 $id = max( get_query_var('p'), get_query_var('page_id'), get_query_var('attachment_id')); 
    87                 if ( $id && $redirect_url = get_permalink($id) ) 
    88                         $redirect['query'] = remove_query_arg(array('p', 'page_id', 'attachment_id'), $redirect['query']); 
     86                $id = max( get_query_var('p'), get_query_var('page_id'), get_query_var('attachment_id') ); 
     87                if ( $id && $redirect_post = get_post($id) ) { 
     88                        if ( 'revision' != $redirect_post->post_type ) { // don't attempt to show revisions 
     89                                $redirect_url = get_permalink($redirect_post); 
     90                                $redirect['query'] = remove_query_arg(array('p', 'page_id', 'attachment_id'), $redirect['query']); 
     91                        } 
     92                } 
    8993         
    9094                if ( ! $redirect_url ) 
    9195                        $redirect_url = redirect_guess_404_permalink();