Cannot access Page if an existing Media item has the same name/slug
|Reported by:||batmoo||Owned by:|
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.