Make WordPress Core


Ignore:
Timestamp:
12/05/2016 07:38:16 PM (8 years ago)
Author:
westonruter
Message:

Customize: Defer populating post_name for auto-draft posts in customized state until posts are published.

The ultimate post_name is stored in postmeta until the post is published. The get_page_by_path() function does not exclude auto-draft posts. Revert changes to wp_unique_post_slug() from [39411] which excluded auto-draft posts.

Props westonruter, dlh for testing, helen for testing.
Merges [39506] onto 4.7 branch.
Fixes #39078 for 4.7.

Location:
branches/4.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-includes/post.php

    r39463 r39507  
    36793679    if ( 'attachment' == $post_type ) {
    36803680        // Attachment slugs must be unique across all types.
    3681         $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_status != 'auto-draft' AND post_name = %s AND ID != %d LIMIT 1";
     3681        $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1";
    36823682        $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) );
    36833683
     
    37073707         * namespace than posts so page slugs are allowed to overlap post slugs.
    37083708         */
    3709         $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";
     3709        $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";
    37103710        $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID, $post_parent ) );
    37113711
     
    37313731    } else {
    37323732        // Post slugs must be unique across all posts.
    3733         $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";
     3733        $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
    37343734        $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) );
    37353735
Note: See TracChangeset for help on using the changeset viewer.