Ticket #15665 (new defect (bug))

Opened 18 months ago

Last modified 3 weeks ago

Page name won't work if the parent page has an attachment with the same name

Reported by: designsimply Owned by:
Priority: normal Milestone: Future Release
Component: General Version: 3.1
Severity: normal Keywords: has-patch needs-testing 3.2-early needs-refresh
Cc: westi, ipstenu@…

Description

It's possible to create a page name that has the same name as an attachment page with the same parent. If you do that, the attachment page takes precedent and it's not possible to display the page with the matching name.

To reproduce:

  1. Create a page, attach some images to it, save and publish
  2. Create a child page with the same name as one of images attached to the parent page

---> Result: a page name and an attachment page name that are the same and it's not possible to view the page at  http://example.com/parent_page_name/page_name/

Tested with r16708

Making the attachment post type hierarchical fixes it this my tests. Is there any reason attachment post types should not be hierarchical?

Attachments

post.diff Download (517 bytes) - added by designsimply 18 months ago.
garyc40.15665.diff Download (1.0 KB) - added by garyc40 17 months ago.
fixed get_page_by_path()

Change History

This is definitely duplicating another ticket somewhere. But I think this is the first time I've seen it well-explained and with a patch. :)

  • Keywords needs-patch added; has-patch, needs-testing removed
  • Milestone changed from Awaiting Review to Future Release

Making the attachment post type hierarchical fixes it this my tests. Is there any reason attachment post types should not be hierarchical?

Yes, attachments are not hierarchical because it doesn't make sense to link an attachment to another attachment.

We should find a better way to fix this.

comment:3 follow-up: ↓ 10   westi18 months ago

I suspect the real fix here is to find out why we match attachment slugs when looking up root level pages

  • Cc westi added

Found two additional cases where it's possible to add pages that conflict with auto-generated pages:

  • author/EXISTING_BLOG_USER
  • category/EXISTING_CATEGORY

This is in addition to the case originally reported where it's possible to add a page that conflicts with existing attachment pages names for the same parent page:

  • PARENT_PAGE/ATTACHMENT_PAGE

fixed get_page_by_path()

  • Keywords has-patch needs-testing 3.2-early added; needs-patch removed

Can't reproduce your problem with author and category though. More detailed steps?

  • Keywords needs-refresh added

Closed #16438 as a duplicate.

  • Cc ipstenu@… added

comment:10 in reply to: ↑ 3 ; follow-up: ↓ 11   duck_5 months ago

#19683 was closed as a duplicate, apparently root level pages were not susceptible to collisions prior to 3.3. This is might due to changes in get_page_by_path(), see #16687.

Replying to westi:

I suspect the real fix here is to find out why we match attachment slugs when looking up root level pages

get_page_by_path() queries for attachment as well as the specified post type.

Related #17170.

comment:11 in reply to: ↑ 10   duck_5 months ago

Replying to duck_:

apparently root level pages were not susceptible to collisions prior to 3.3.

Sorry for repeating that without double checking. It's wrong.

Closed #20612 as a duplicate.

Note: See TracTickets for help on using tickets.