WordPress.org

Make WordPress Core

Ticket #13125: 13125-2.patch

File 13125-2.patch, 960 bytes (added by night815, 4 years ago)

small format changes to adhere to the coding standards

  • wp-includes/canonical.php

     
    8282        // These tests give us a WP-generated permalink 
    8383        if ( is_404() ) { 
    8484                $redirect_url = redirect_guess_404_permalink(); 
     85 
     86                // #13125: redirect p=NNN links to page_id=NNN (if page exists) instead of 404ing 
     87                if ( $id = get_query_var('p') ) { 
     88                        $type = $wpdb->get_var( $wpdb->prepare("SELECT post_type FROM $wpdb->posts WHERE ID = %d", $id ) ); 
     89                        if ( $type && 'page' == $type ) { 
     90                                $redirect['query'] = remove_query_arg(array('p', 'page_id'), $redirect['query']); 
     91                                $redirect_url = get_permalink($id); 
     92                        } 
     93                } 
    8594        } elseif ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) { 
    8695                // rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101 
    8796                if ( is_attachment() && !empty($_GET['attachment_id']) && ! $redirect_url ) {