Make WordPress Core

Opened 6 years ago

Closed 5 years ago

Last modified 2 years ago

#43001 closed defect (bug) (wontfix)

Page Slug and Attachment - Conflict

Reported by: sebastianpisula's profile sebastian.pisula Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.1
Component: Posts, Post Types Keywords: has-patch
Focuses: Cc:


I found problem. My attachment have post_name "test" and I want set for my new page post_name "test" and WordPress generate "test-2". I think that problem is with wp_unique_post_slug function in file: wp-includes/post.php:3950:

$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";

I attach fix

Attachments (1)

43001.patch (918 bytes) - added by sebastian.pisula 6 years ago.

Download all attachments as: .zip

Change History (4)

#1 @sebastian.pisula
6 years ago

  • Keywords has-patch added

#2 @swissspidy
6 years ago

Note that media items which aren't attached to a post can be accessed via, hence this check within wp_unique_post_slug(). Your patch would break that behaviour.

#3 @SergeyBiryukov
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

As noted above, the check for attachment post type was intentionally added to wp_unique_post_slug() in [30629] to avoid creating a page with a slug which conflicts with an existing attachment.

The proposed change would introduce a regression. Thanks for the patch though!

Note: See TracTickets for help on using tickets.