WordPress.org

Make WordPress Core

Ticket #13459: 13459.patch

File 13459.patch, 1.2 KB (added by SergeyBiryukov, 15 months ago)
  • wp-includes/post.php

     
    31313131                // Post slugs must be unique across all posts. 
    31323132                $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1"; 
    31333133                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) ); 
     3134                if ( ! $post_name_check && '/%postname%/' == $wp_rewrite->permalink_structure ) 
     3135                        $post_name_check = get_page_by_path( $slug ); 
    31343136 
    31353137                if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) ) { 
    31363138                        $suffix = 2; 
    31373139                        do { 
    31383140                                $alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; 
    31393141                                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_ID ) ); 
     3142                                if ( ! $post_name_check && '/%postname%/' == $wp_rewrite->permalink_structure ) 
     3143                                        $post_name_check = get_page_by_path( $alt_post_name ); 
    31403144                                $suffix++; 
    31413145                        } while ( $post_name_check ); 
    31423146                        $slug = $alt_post_name;