page and attachment conflict
|Reported by:||ejikas||Owned by:|
this bug noticed on 3.0.4 and also in the 3.1-RC3-17376. Also I noticed it was written about it 4months ago in support forum: http://wordpress.org/support/topic/attachment-post-slug-not-being-checked-for-duplicates
In short: instead of the page getting attachment page.
How to see the bug:
- using permalinks.
- upload an image to the media gallery.
- created Page with the same slug like was the file name.
if the file name was 1-200x150.jpg so page slug should be 1-200x150,
if the file name was about-group.jpg so the new page slug should be about-group.
- publish the page and try to view it. Instead of the page you will get the attachment page.
if you would insert the image to any post/page the bug would dissapear. even after you remove the image from the page content (it remains in the page gallery)
or in other words the function get_page_by_path(), that is in wp-includes/post.php, line #2890.
it's easy to see if both page and attachment share one slug and the attachment has no "parent" it leads to the bug.
not sure why the it is used function get_page_by_path() that queries not only pages but attachments too. I think there should be called function like get_page_by_slug (or ..by_name) that queries only page type records. If I'm not mistaken for attachments and attachment pages wp generates different rewrite rules with no var "pagename". If I'm right should be changed the call in query.php