Make WordPress Core

Opened 14 years ago

Last modified 6 years ago

#17170 new defect (bug)

Attachment slugs are not unique

Reported by: duck_'s profile duck_ Owned by:
Milestone: Priority: normal
Severity: major Version: 2.8
Component: Permalinks Keywords: has-patch 2nd-opinion
Focuses: Cc:

Description

From wp_unique_post_slug() and #9726:

Attachment slugs must be unique across all types.

It's true that attachment slugs are checked for uniqueness against all other object types, however, when inserting an object of another type any uniqueness checks do not include attachments. This means that #9539 isn't actually fixed if you attempt the steps in the order described (insert attachment first followed by conflicting page).

Fix would be to add 'attachment' to the post_type IN clause for hierarchical types. See attachments-hierarchically-unique.diff.

Still puzzling out why/if attachments need to be unique against non-hierarchical types since there shouldn't be collisions as attachment URLs are subpage style. However, if attachment slugs do need to be globally unique then see attachments-globally-unique.diff (not tested so much).

Related: #9726, #9539, #6437, [11467]

Attachments (3)

attachments-hierarchically-unique.diff (1.1 KB) - added by duck_ 14 years ago.
attachments-globally-unique.diff (1.7 KB) - added by duck_ 14 years ago.
17170.diff (730 bytes) - added by DrewAPicture 9 years ago.

Download all attachments as: .zip

Change History (5)

#1 @nacin
11 years ago

  • Component changed from General to Permalinks
  • Severity changed from normal to major

@DrewAPicture
9 years ago

#2 @DrewAPicture
9 years ago

Looks like the change for hierarchically-unique attachment slugs was made about nine months ago in [30629]. Refreshed the patch as 17170.diff for the regular unique attachment slugs.

Since @boonebgorges was the author for [30629], I thought perhaps he might weigh in here on finishing this out (or not).

Last edited 9 years ago by DrewAPicture (previous) (diff)
Note: See TracTickets for help on using tickets.