Make WordPress Core

Ticket #60941: 60941.diff

File 60941.diff, 1.8 KB (added by nikunj8866, 6 months ago)

I have attached my patch.

  • src/wp-includes/post.php

    diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
    index 2a02400bd1..3042ec7ddc 100644
    a b function wp_unique_post_slug( $slug, $post_id, $post_status, $post_type, $post_p 
    51655165                 * Page slugs must be unique within their own trees. Pages are in a separate
    51665166                 * namespace than posts so page slugs are allowed to overlap post slugs.
    51675167                 */
    5168                 $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";
     5168                if ( 'page' === $post_type ) {
     5169                        $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( %s, 'post', 'attachment' ) AND ID != %d AND post_parent = %d LIMIT 1";
     5170                } else {
     5171                        $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";
     5172                }
    51695173                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_id, $post_parent ) );
    51705174
    51715175                /**
    function wp_unique_post_slug( $slug, $post_id, $post_status, $post_type, $post_p 
    51955199                }
    51965200        } else {
    51975201                // Post slugs must be unique across all posts.
    5198                 $check_sql       = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
     5202                if ( 'post' === $post_type ) {
     5203                        $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN( %s, 'page' ) AND ID != %d LIMIT 1";
     5204                } else {
     5205                        $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
     5206                }
    51995207                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_id ) );
    52005208
    52015209                $post = get_post( $post_id );