WordPress.org

Make WordPress Core

Ticket #11863: post.patch

File post.patch, 1.5 KB (added by williamsba1, 5 years ago)
  • post.php

     
    24302430        } elseif ( in_array( $post_type, $hierarchical_post_types ) ) { 
    24312431                // Page slugs must be unique within their own trees. Pages are in a separate 
    24322432                // namespace than posts so page slugs are allowed to overlap post slugs. 
    2433                 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( '" . implode( "', '", esc_sql( $hierarchical_post_types ) ) . "' ) AND ID != %d AND post_parent = %d LIMIT 1"; 
     2433                $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( '" . implode( "', '", esc_sql( $hierarchical_post_types ) ) . "' ) AND ID != %d AND post_parent = %d AND post_status <> 'trash' LIMIT 1"; 
    24342434                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID, $post_parent ) ); 
    24352435 
    24362436                if ( $post_name_check || in_array( $slug, $feeds ) || preg_match( '@^(page)?\d+$@', $slug ) ) { 
     
    24442444                } 
    24452445        } else { 
    24462446                // Post slugs must be unique across all posts. 
    2447                 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1"; 
     2447                $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d AND post_status <> 'trash' LIMIT 1"; 
    24482448                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) ); 
    24492449 
    24502450                if ( $post_name_check || in_array( $slug, $feeds ) ) {