Make WordPress Core

Opened 9 years ago

Last modified 5 years ago

#31300 new defect (bug)

redirect_canonical returns too early

Reported by: stephenharris's profile stephenharris Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Canonical Keywords: has-patch dev-feedback
Focuses: Cc:


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)

31300.diff (994 bytes) - added by stephenharris 9 years ago.

Download all attachments as: .zip

Change History (5)

9 years ago

#1 @stephenharris
9 years ago

  • Keywords has-patch dev-feedback added

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.

#2 @DrewAPicture
9 years ago

  • Version trunk deleted

#3 @mikejolley
8 years ago

I could also use this one - - 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.

This ticket was mentioned in Slack in #core by lkraav. View the logs.

5 years ago

Note: See TracTickets for help on using tickets.