Opened 3 years ago
Last modified 2 weeks ago
#14639 new defect (bug)
Posts in the Trash drag attachment pages down with them
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Media | Version: | 3.0.1 |
| Severity: | normal | Keywords: | |
| Cc: | ryan@…, westi, knut@…, dailyrants@… |
Description
If you have an attachment linked to a post, then move the post to the Trash, the attachment page results in a 404.
Steps to reproduce:
- Create a new post with at least one image attached to it (just add it to the post).
- Publish the post.
- Check both the attachment URL (it will be a "child" of the post to which it is attached) and the post URL.
- Move the post to the Trash.
- Try to "View" the attachment either by going through the Media Library or by refreshing the attachment URL. WordPress will display a 404 message.
Deleting the post permanently can cause the attachment permalink to work again, both with the page parent in the slug and without that information in the form http://sitename.com/attachmentname/ .
Change History (9)
Point taken.
I'll argue then instead that the permalink should also result in a 404 when the post has been permanently deleted.
If you plan on leaving it that way so that posts that are trashed take down all the attachments with-it then the user interface shouldn't allow users create galleries with attachments from other posts.
- Cc dailyrants@… added
This affects other posts too, not just the original post to which a media item is attached.
For example, if you add the same image to two posts, and set it to link to the attachment page in both posts, it breaks the link in the second post when the first post is deleted or set as a draft.
It's kinda tricky. On the one hand, you might want a media item's visibility linked to the post it is attached to. On the other, it pretty much messes with the concept of a central media library. When a media item is "attached" to something, it's no longer a neutral object available for use everywhere without conditions. If it's simply referenced and not attached, its usable everywhere and its permalink is tied to itself instead of another object.
To the point made by the OP about what happens when the original post is emptied from the trash, it's just weird that the permalink of the attachment begins to work again and still lives at a location attached to the original post slug. site.com/deleted-post-title/attachment. That just seems wrong.
Any "solution" to this seems equally annoying from a UI perspective, as one would need to declare that an item is either attached to another object or is a global asset to be referenced as a unique independent asset.
One that comes to mind, but isn't obvious without people discovering it through trial and error, is that if an item is uploaded by Media > Add New, it is an independent object forever. If it is ever inserted into a post via the "Add Media" button later, it remains independent and is only accessed via the HTML code that gets inserted into the post. If it's initially inserted into a post via the "Add Media" button in the post editor screen, it becomes tied to that object as it currently does.
I'm very likely overlooking something here, but the current situation seems far less than ideal. Does anyone else have any insight here?
comment:9
in reply to:
↑ 8
SergeyBiryukov — 2 weeks ago
Replying to mindctrl:
To the point made by the OP about what happens when the original post is emptied from the trash, it's just weird that the permalink of the attachment begins to work again and still lives at a location attached to the original post slug. site.com/deleted-post-title/attachment. That just seems wrong.
Actually, once the post is deleted, the attachment permalink in Media Library changes to numeric form (e.g. http://trunk.wordpress/?attachment_id=5186). The old permalink, however, still continues to work. It should probably redirect to the new one.

Attachments inherit post status from the post they are attached too so they should behave as if they were no longer published which is what is happening here.
Why would you expect otherwise?