WordPress.org

Make WordPress Core

Ticket #13459: 13459.2.patch

File 13459.2.patch, 1.1 KB (added by moraleida.me, 10 months ago)

Exact same patch from SergeyBiryukov, reapplied to current codebase

  • post.php

     
    30723072                $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1"; 
    30733073                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) ); 
    30743074 
     3075                if ( ! $post_name_check && '/%postname%/' == $wp_rewrite->permalink_structure ) 
     3076                        $post_name_check = get_page_by_path( $slug ); 
     3077 
    30753078                if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) ) { 
    30763079                        $suffix = 2; 
    30773080                        do { 
    30783081                                $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; 
    30793082                                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_ID ) ); 
     3083                                 
     3084                                if ( ! $post_name_check && '/%postname%/' == $wp_rewrite->permalink_structure ) 
     3085                                        $post_name_check = get_page_by_path( $alt_post_name ); 
     3086                                 
    30803087                                $suffix++; 
    30813088                        } while ( $post_name_check ); 
    30823089                        $slug = $alt_post_name;