Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#20612 closed defect (bug) (duplicate)

Cannot access Page if an existing Media item has the same name/slug

Reported by: batmoo's profile batmoo Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

When using pretty permalinks, an existing media item with the same slug as a page will override access to that page.

Steps to reproduce, from the Dashboard:

  • Media > Add New (rename any image to test.png and upload)
  • You can view the media item at /test/
  • Pages > Add New (Set "Test" as the title and pubish)
  • Viewing the published page (also /test/) will show you the media item.

The page added in the last step 3 has the same slug as the media item. Clicking on "View Page" will show you the media item. Even the unpretty permalink does not work: ?pagename=test

The query generated by WordPress looks for both pages and attachments, which is why this conflict happens:

SELECT ID, post_name, post_parent FROM vip_posts WHERE post_name IN ('test') AND (post_type = 'page' OR post_type = 'attachment')

There should be some sort of constraint that prevents this.

Change History (2)

#1 @SergeyBiryukov
11 years ago

  • Description modified (diff)

#2 @SergeyBiryukov
11 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.