WordPress.org

Make WordPress Core

Ticket #38928: 38928.2.diff

File 38928.2.diff, 2.0 KB (added by westonruter, 5 years ago)
  • src/wp-includes/post.php

    diff --git src/wp-includes/post.php src/wp-includes/post.php
    index 620d1e4..2c70fdd 100644
    function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p 
    36733673
    36743674        if ( 'attachment' == $post_type ) {
    36753675                // Attachment slugs must be unique across all types.
    3676                 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1";
     3676                $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_status != 'auto-draft' AND post_name = %s AND ID != %d LIMIT 1";
    36773677                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) );
    36783678
    36793679                /**
    function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p 
    37013701                 * Page slugs must be unique within their own trees. Pages are in a separate
    37023702                 * namespace than posts so page slugs are allowed to overlap post slugs.
    37033703                 */
    3704                 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( %s, 'attachment' ) AND ID != %d AND post_parent = %d LIMIT 1";
     3704                $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_status != 'auto-draft' AND post_name = %s AND post_type IN ( %s, 'attachment' ) AND ID != %d AND post_parent = %d LIMIT 1";
    37053705                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID, $post_parent ) );
    37063706
    37073707                /**
    function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p 
    37253725                }
    37263726        } else {
    37273727                // Post slugs must be unique across all posts.
    3728                 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
     3728                $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_status != 'auto-draft' AND post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
    37293729                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) );
    37303730
    37313731                // Prevent new post slugs that could result in URLs that conflict with date archives.