From db9b25fbc57c3d8bffde94a2cf54e211dc3c1fca Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Sun, 30 Nov 2014 04:49:22 +0000 Subject: [PATCH] Check attachments as well as the current post type when checking for duplicate post slugs. This avoids creating a page with a slug which conflicts with an existing attachment (the inverse is already handled). Updates the existing test for pages which should take priority over attachments in cases where an existing clash exists. Fixes #18962 Props boonebgorges Built from https://develop.svn.wordpress.org/trunk@30629 git-svn-id: http://core.svn.wordpress.org/trunk@30619 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 2 +- wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 3b3d55fe19..37f97d97fb 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -3703,7 +3703,7 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p * Page slugs must be unique within their own trees. Pages are in a separate * namespace than posts so page slugs are allowed to overlap post slugs. */ - $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d AND post_parent = %d LIMIT 1"; + $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"; $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID, $post_parent ) ); /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 17c5e0c09c..c24b312ce0 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.1-beta2-30628'; +$wp_version = '4.1-beta2-30629'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.