[wp-trac] [WordPress Trac] #18962: Allow duplicate slugs for different content

WordPress Trac noreply at wordpress.org
Sat Nov 22 12:24:18 UTC 2014


#18962: Allow duplicate slugs for different content
---------------------------------------------+-----------------------------
 Reporter:  maorb                            |       Owner:  wonderboymusic
     Type:  defect (bug)                     |      Status:  reopened
 Priority:  normal                           |   Milestone:  4.1
Component:  Permalinks                       |     Version:  2.9
 Severity:  major                            |  Resolution:
 Keywords:  has-patch commit has-unit-tests  |     Focuses:
---------------------------------------------+-----------------------------

Comment (by boonebgorges):

 Replying to [comment:40 dd32]:
 > @wonderboymusic - How does this change handle attachments?
 >
 > Attachments need to be unique across all post types (I'm not entirely
 sure why, but that's what the code says), take this scenario:
 > 1. Create a page /test/
 > 2. Upload a file which ends up at /test/example/
 > 3. Create a page /test/example/
 >
 > Previously creating the page would be blocked and created as
 /test/example-2, but it looks like this now allows that, and as a result
 the post_type check should be changed to `post_type IN( $post_type,
 'attachment')`?
 >
 > Re-opening pending that and #30339

 I can't reproduce this previous behavior. On 4.0, reating that page
 /test/example/ will successfully create a page with the slug 'example',
 creating a URL clash with the attachment. The changes in [21845] mean that
 the page always wins, so that the attachment page is inaccessible. (See
 #15665.) And, in fact, if what dd32 is saying here were true, I'm not sure
 how `test_get_page_by_path_priority()` ever would have passed.

 My interpretation is: [21845] didn't really fix the problem. It put the
 fix in the URL parser (`get_page_by_path()`) when it should have prevented
 the duplicate slug to begin with. dd32's suggestion with
 [attachment:18962.2.diff] seems like it's the correct fix for the current
 ticket, and it also seems like a partial fix for #15665. (The "proper" fix
 for the latter ticket would probably be more specific: when creating an
 attachment, check that the parent post doesn't have a child with the same
 slug, and vice versa.)

--
Ticket URL: <https://core.trac.wordpress.org/ticket/18962#comment:45>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list