[wp-trac] [WordPress Trac] #16438: page and attachment conflict
WordPress Trac
wp-trac at lists.automattic.com
Wed Feb 2 00:28:33 UTC 2011
#16438: page and attachment conflict
--------------------------+-----------------------------
Reporter: ejikas | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 3.0.4
Severity: critical | Keywords:
--------------------------+-----------------------------
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:
0. using permalinks.
1. upload an image to the media gallery.
2. 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.
3. 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)
-----------------------------------------------------------
the bug is there:
file: wp-includes/query.php,
line #1509: $this->queried_object =& get_page_by_path($qv['pagename']);
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.
---------------------------------
suggestion/question:
---------------------------------
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
--
Ticket URL: <http://core.trac.wordpress.org/ticket/16438>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list