Make WordPress Core

Opened 9 years ago

Last modified 6 years ago

#34972 new defect (bug)

Permalink for unattached media same as a post

Reported by: petercralen's profile petercralen Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 4.4
Component: Permalinks Keywords: needs-patch needs-unit-tests
Focuses: Cc:

Description

First step - upload media "tralala.jpg" I got pretty link example.com/tralala/
Second step - create a post with Title "Tralala" it creates post with slug example.com/tralala/ this works.
So post with the same title as unattached media filename creates the same permalink - slug as already exists for unattached media.
In this case, unattached media is unreachable as permalink point to new post with the same slug.

Change History (8)

#1 @petercralen
9 years ago

This applies to post only, not a page or another media upload with the same name. For pages and another media upload, it works well, it creates slug /tralala-2/ ...

#2 @johnbillion
9 years ago

  • Keywords needs-patch needs-unit-tests added
  • Milestone changed from Awaiting Review to Future Release

Confirmed.

#3 @SergeyBiryukov
9 years ago

This was somewhat alleviated in #24612 (previously, the post was inaccessible).

A proper fix should prevent the conflict from occuring, probably via #13459.

Last edited 9 years ago by SergeyBiryukov (previous) (diff)

#4 in reply to: ↑ description @Asajoarder
9 years ago

  • Focuses accessibility template added
  • Severity changed from normal to blocker

Replying to petercralen:

First step - upload media "tralala.jpg" I got pretty link example.com/tralala/
Second step - create a post with Title "Tralala" it creates post with slug example.com/tralala/ this works.
So post with the same title as unattached media filename creates the same permalink - slug as already exists for unattached media.
In this case, unattached media is unreachable as permalink point to new post with the same slug.

#5 @SergeyBiryukov
9 years ago

  • Focuses accessibility template removed
  • Severity changed from blocker to normal

#6 @mdgl
8 years ago

Sorry I'm new to this one but have just noticed similar problems with the permalinks for unattached media on my site.

It seems that the changes released in 4.4 under #1914 mean that permalinks of the form site/%media-file-name%/ are now generated for all unattached media items. It does not seem to be possible to change this generated permalink once the media item has been uploaded.

Although this may be considered an improvement, it seems likely to cause much opportunity for duplicate/clashing permalinks with other pages, posts or custom post types. You now need to be very careful to consider the file names of media before you upload!

At the very least, I suspect such permalinks should be individually editable in the same way as they are for pages and posts. It should probably also be possible to set a "base" for these permalinks using the Settings->Permalinks screen and similar to categories and tags, so that the site namespace can be managed properly (e.g. by pushing all unattached media under the path site/media/ or similar).

As I see it, for too long WordPress has confused the meaning of media, images and attachments. A longer term plan would also be useful to resolve this and provide improved management of such content.

See also #35529.

#7 @henry.wright
8 years ago

There's 4 solutions I can think of.

  1. Allow the slug of unattached media to be editable
  1. Prepend a hard "base" to the URL. For example /media/media-item
  1. Allow the permalink structure for unattached media to be set in the admin area
  1. Check if the media item's slug is unique across both media items and pages before assigning it. If not unique, append something.
Last edited 8 years ago by henry.wright (previous) (diff)

#8 @SergeyBiryukov
6 years ago

I thought [30629] should have fixed this, but still can reproduce the issue in current trunk, so apparently it did not.

Note: See TracTickets for help on using tickets.