Opened 10 years ago
Last modified 5 years ago
#31300 new defect (bug)
redirect_canonical returns too early
Reported by: | stephenharris | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Canonical | Keywords: | has-patch dev-feedback |
Focuses: | Cc: |
Description
If $redirect_url
is not set or is not equal to $requested_url
then redirect_canonical()
returns early and does not trigger the redirect_canonical
filter. This prevents plugins from being able to alter the canonical URL.
This bug was partially addressed in #8975 (it still returned early when the redirect and requested URL are the same), but this was reverted in #11700 without any indication as to why.
The attached patch ensures the filter triggers even when the $redirect_url
is not set or is the same as $requested_url
.
Attachments (1)
Change History (5)
#3
@
9 years ago
I could also use this one - https://github.com/woothemes/woocommerce/issues/10619#issuecomment-203039875 - Core handles %category% canonical redirects, but if I want to do the same for a custom one, e.g. %product_category%, I cannot via this filter because it returns too early.
Attached patch passes all canonical group unit tests, with one skipped (open trac ticket). My only concern which this patch is that
redirect_canonical()
seems to modify the$requested_url
between where the early return was and the filter is. I'm confused as to why it modifies the requested URL not the redirect URL, but in my opinion this issue is independent of this ticket.