Make WordPress Core

Ticket #11863: 11863.3.diff

File 11863.3.diff, 1.3 KB (added by williamsba1, 9 years ago)
  • wp-includes/post.php

     
    36103610                }
    36113611        } else {
    36123612                // Post slugs must be unique across all posts.
    3613                 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
    3614                 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) );
     3613                $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d AND post_status = %s LIMIT 1";
     3614                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID, 'publish' ) );
    36153615
    36163616                // Prevent new post slugs that could result in URLs that conflict with date archives.
    36173617                $post = get_post( $post_ID );
     
    36483648                        $suffix = 2;
    36493649                        do {
    36503650                                $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
    3651                                 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_ID ) );
     3651                                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_ID, 'publish' ) );
    36523652                                $suffix++;
    36533653                        } while ( $post_name_check );
    36543654                        $slug = $alt_post_name;