Opened 13 years ago
Closed 9 years ago
#19918 closed defect (bug) (fixed)
Attachments are viewable from any permalink that matches their slug
Reported by: | prorock | Owned by: | wonderboymusic |
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | 3.2 |
Component: | Permalinks | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
I see one problem in WordPress, for example if you upload an images with name comments.png, all your url contain hide url like: /comments
example:
original post: yourdomain.com/myarticle
if you have in media gallery file with name comments.png url will be: yourdomain.com/myarticle/comments
or
yourdomain.com/myarticle2/comments
or
yourdomain.com/myarticle3/comments
and all this url's contain the same comment box.
my users report this problem, because if i share in twitter or g+ one link, many users redirect not to the post but to url with /comments in the end.
Adrian,
designmodo.com
Attachments (3)
Change History (25)
#2
@
13 years ago
Not sure what the problem is. My steps:
- Switched permalink structure to
/%postname%/
. - Created and published a new post: /test8/
- On Edit Post screen, uploaded
comments.jpg
image. - URL of the post is still the same (/test8/) and opens the post without a redirect.
- URL of the uploaded image is /test8/comments/ and opens the image.
#3
@
13 years ago
Sergey, try to create posts like /test9 and /test10 without upload any images and type in browser /test9/comments/ /test9/comments/ will appear the same image that in case of /test8/comments/
#6
@
13 years ago
- Component changed from Comments to Permalinks
- Summary changed from File name convert to URL to Attachments are viewable from any permalink that matches their slug
- Version changed from 3.3.1 to 3.2
This seems to be a wider issue than what was originally reported. Basically, you can view an attachment by appending it's slug to the link for any post! To reproduce:
- Use pretty permalinks (the exact structure doesn't matter)
- Add an attachment to a post (e.g., with attachment URL
/2012/01/30/my-post/my-attachment/
) - Now you can view that attachment by appending the attachment slug to any other post. For example
/2012/01/01/hello-world/my-attachment/
or/2011/11/01/another-random-post/my-attachment/
.
The name of the attachment doesn't matter.
I can reproduce this in WP 3.2 (and 3.3, trunk). Don't have an earlier version running at the moment.
#7
@
13 years ago
- Version changed from 3.2 to 3.3.1
In 3.3.1 is the same problem, so don't change version :)
Thanks
#8
@
13 years ago
- Version changed from 3.3.1 to 3.2
The version field is used to identify the earliest version at which the bug exists. Because it says 3.2 doesn't mean it doesn't exist in 3.3.
#10
@
13 years ago
- Keywords has-patch dev-feedback added
Here's a patch for starters. It fixes the issue for me, but I'm not too familiar with canonical so there is probably a better/more correct way to do it.
#11
@
10 years ago
- Severity changed from major to normal
Patch still looks good to go, but the severity of this issue isn't "major", as it doesn't really break anything. Downgrading to normal.
#14
@
9 years ago
- Keywords needs-patch added; has-patch removed
- Resolution fixed deleted
- Status changed from closed to reopened
[34272] broke attachment endpoints
To reproduce:
- Add a rewrite endpoint, e.g. by using
add_rewrite_endpoint( 'embed', EP_ALL );
or justadd_rewrite_endpoint( 'embed', EP_ATTACHMENT );
- Upload an attachment to a post.
- Visit the attachment URL with that endpoint, e.g.
http://example.org/my-awesome-post/sample-attachment/embed/
. redirect_canonical
redirects you tohttp://example.org/my-awesome-post/sample-attachment/
#15
@
9 years ago
- Owner changed from Adrian (designmodo.com) to wonderboymusic
- Status changed from reopened to assigned
#17
follow-up:
↓ 18
@
9 years ago
These two recent commits triggered a circular redirect in some themes on wp.com. Those themes filter attachment_link
to add a fragment #main
, and that interacts with the new code to redirect back to the same url.
For an example, see suburbia_enhanced_image_navigation
in https://wpcom-themes.svn.automattic.com/suburbia/functions.php.
I checked with our theme team, and they think it's reasonable behaviour for a theme to do that. It's also likely that other, non-Automattic themes do something similar.
I'm not really sure what the solution is, or even if there could be a third factor interacting, but I did confirm that reverting those two commits stops the circular redirect from happening.
#18
in reply to:
↑ 17
@
9 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Replying to tellyworth:
These two recent commits triggered a circular redirect in some themes on wp.com. Those themes filter
attachment_link
to add a fragment#main
, and that interacts with the new code to redirect back to the same url.
I'm reasonably convinced that this is a general problem in redirect_canonical()
. If any of the functions used to generate a canonical URL (such as get_permalink()
) are filtered to add a #fragment, this causes the circular redirect detection logic to fail.
attachment:19918-circular-fragment.diff prevents this from happening. It fixes the attachment issue, and shouldn't prevent redirecting to a URL that contains a fragment, which is probably a valid use case.
#19
@
9 years ago
- Keywords has-patch has-unit-tests added; needs-patch removed
19918.2.diff fixes the patch, which had the wrong var in it, $redirect_url
, which was blowing up unit tests.
This ticket was mentioned in Slack in #core by wonderboymusic. View the logs.
9 years ago
#21
@
9 years ago
@wonderboymusic New function could use a @since
annotation, but otherwise +1 from me on 19918.2.diff
This would likely also effect images named page, feed, or trackback as well.