WordPress.org

Make WordPress Core

Opened 22 months ago

Last modified 13 months ago

#24612 reopened defect (bug)

Permalink conflict: image attachment page and post when permalink setting is /%postname%/

Reported by: augustas Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.3
Component: Permalinks Keywords: has-patch needs-unit-tests
Focuses: Cc:

Description

Here is scenario when there is a permalink conflict between the "attachment page" URL and post when image filename and post name are equal:
Permalinks are set to /%postname%/

Using Media -> Library -> upload new image called about-me.jpg
System saves into "wp_posts" database table: post_name = "about-me"

I publish a new POST with the title "About Me". For this post database stores the post_name = "about-me"

If I go to URL: www.example.com/about-me/ - I am redirected to about-me.jpg Image Attachment Page.

If POST is created first and the image uploaded second - URL will open the POST.

This issue is similar to #13459

Attachments (1)

24612.patch (1.2 KB) - added by SergeyBiryukov 13 months ago.

Download all attachments as: .zip

Change History (7)

comment:1 @augustas22 months ago

  • Summary changed from Permalink conflict when image is not attached to the post and permalink setting is /%postname%/ to Permalink conflict: image attachment page and post when permalink setting is /%postname%/

comment:2 @SergeyBiryukov22 months ago

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

comment:3 @SergeyBiryukov13 months ago

  • Milestone set to Awaiting Review
  • Resolution duplicate deleted
  • Status changed from closed to reopened

Reopening per ticket:15665:28, as #15665 only covered pages.

comment:4 @aaroncampbell13 months ago

I ran into this yesterday. I definitely think that posts should take precedence over attachments in this case. Especially since the UI to change media slugs is hidden in screen options by default.

@SergeyBiryukov13 months ago

comment:5 @SergeyBiryukov13 months ago

  • Keywords has-patch needs-unit-tests added
  • Version changed from 3.5.1 to 3.3

Introduced in [18541], specifically with the changes in WP_Rewrite::page_rewrite_rules().

24612.patch fixes it for me.

Last edited 13 months ago by SergeyBiryukov (previous) (diff)

comment:6 @aaroncampbell13 months ago

24316.patch works for me. It's very specific to "post" though. Do we want to assume that handling slug conflicts for custom post types should be done in the plugin that creates the post type?

Note: See TracTickets for help on using tickets.