[wp-trac] [WordPress Trac] #24612: Permalink conflict: image attachment page and post when permalink setting is /%postname%/
WordPress Trac
noreply at wordpress.org
Wed Jul 15 03:07:50 UTC 2015
#24612: Permalink conflict: image attachment page and post when permalink setting
is /%postname%/
----------------------------------------+------------------------------
Reporter: augustas | Owner:
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: Awaiting Review
Component: Permalinks | Version: 3.3
Severity: normal | Resolution:
Keywords: has-patch needs-unit-tests | Focuses:
----------------------------------------+------------------------------
Comment (by dmchale):
Thanks for that workaround @SergeyBirukov it worked perfectly on one of my
client sites. (the latest patch did not. I tried to update query.php with
the code changes in that patch manually, just to see if it was viable, but
it seems the fact that the code did not set `queried_object_id` or
`is_single` was causing problems)
Unfortunately, this issue has bitten me TWICE in the past 2 weeks at my
day job, after 3 years of never having knowingly run into it before. I
think a good part of the trouble stems from our SEO department wanting to
ensure that all of our file names are now "search engine friendly" and as
such have been trying to name documents and images more intelligently now
on our client sites. Due to this, they HAPPEN to be naming some
images/files the same as other objects within the system and it's causing
issues when all of a sudden a section of the website "disappears" and site
visitors are redirected to a PDF file rather than the content they were
supposed to be served.
I did a bit of testing at home on my VVV setup tonight, and documented
some of my steps and my findings as I went. I would love to help talk
through a workaround that could be implemented in core, if possible. Since
I don't have any history with how/why things were made getting to this
point, I'm not sure why some design decisions were made. I did go through
all of the tickets referenced by this ticket though, so I have at least
read up a good deal on some others' issues with dealing with the same
thing.
My notes are below..... apologies for length, I tried to be thorough.
start with clean install of trunk
set permalinks to /%post-name%/
created "Permalink" PAGE (system gave it a slug of /permalink/)
created "Permalink" POST (system gave it a slug of /permalink/)
Already have a conflict. Why can POSTS create a shared slug as
PAGES?
uploaded permalink.pdf (system gave it a slug of /permalink-2/)
- Side note, the "permalink" shown at the top of the page still shows the
native /attachment_id=N format, which obviously does not match my
permalink setting. Is this by design, or something that should be
addressed? It's misleading at best.
View /permalink/, system displays the PAGE content
Edit PAGE, update permalink to /permalink-page/
Refresh /permalink/, system now displays the POST content
- While a PAGE and POST existed with the name conflict, the PAGE always
"won"
Edit POST, update permalink to /permalink-post/
Refresh /permalink/, WP now redirects to /permalink-post/
Upload permalink-post.pdf (system gave it a slug of /permalink-post-2/)
No conflict!
<Conclusion: you cannot create a slug conflict by uploading media
files after an existing post type "owns" the slug> ..... Challenge: Is
this true for all post types, CPTs included, or only pages/posts? Need to
test.
Upload permalink-file.pdf (system gave it a slug of /permalink-file/)
Create POST called "permalink file" (system gave it a slug of /permalink-
file/)
Viewed /permalink-file/, system shows the media page with a link to
download the PDF
<Conclusion: you CAN create a post that will cause a naming
conflict with a pre-existing media library item (as well as PAGE)>
Deleted "permalink file" POST, removed it from trash
Create PAGE called "permalink file" (system gave it a slug of /permalink-
file-2/)
No conflicts!
<Conclusion: Add New Page behavior respects `attachment` post
types, while Add New Post does not>
Takeaways....
- It is currently impossible to create a naming conflict between
pages/attachments. No matter which you create first, the second one will
pick a unique slug.
- `Add/Edit Post` should be updated to mimic `Add New Page` functionality,
at least in regards to preventing naming conflicts with `attachment` post
types.
- Permalinks/slugs have been demoted in the media library to the point of
obvious confusion.
- - The current behavior of the system to use the slug as a permalink, but
never SAYS this is the case. This seems to be a massive UI failure.
- - Slug editing is disabled from Screen Options by default, which makes
things even more challenging to troubleshoot in this scenario
- Would suggest that "Permalinks" on the media edit page be updated to
behave the same way pages/posts do, so the slug can be modified in place
at the end of the url.
- - The screen could also CONTINUE to show the permanent link to the
/?attachment_id=N url as well below, which would remain unchangeable.
- Bottom line, my belief is that the post/page/attachment post types
should all respect each other out of the box and never create naming
conflicts with each other. The matter of whether this is done ONLY when WP
is set to /%post-name%/ setting, or always, can easily be a talking point.
If naming conflicts were created because of/during the changing of the
permalink setting, that's something a site admin could/would/(should?)
have to address at that time. That job could even be plugin territory, an
opportunity for someone to write a tool that would address that for
people.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/24612#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list