Ticket #11863: 11863.3.diff
File 11863.3.diff, 1.3 KB (added by , 9 years ago) |
---|
-
wp-includes/post.php
3610 3610 } 3611 3611 } else { 3612 3612 // 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' ) ); 3615 3615 3616 3616 // Prevent new post slugs that could result in URLs that conflict with date archives. 3617 3617 $post = get_post( $post_ID ); … … 3648 3648 $suffix = 2; 3649 3649 do { 3650 3650 $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' ) ); 3652 3652 $suffix++; 3653 3653 } while ( $post_name_check ); 3654 3654 $slug = $alt_post_name;