Make WordPress Core

Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#42313 closed enhancement (fixed)

Introduce an X-Redirect-By header

Reported by: joostdevalk's profile joostdevalk Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.1 Priority: normal
Severity: normal Version:
Component: Canonical Keywords: has-patch
Focuses: Cc:

Description

Diagnosing redirect loops can often be very confusing because many parts of a system can perform a redirect. The introduction of the X-Redirect-By header would allow the application to be identified more easily.

Yoast SEO already sends this header and we've found it to be very useful many a time, at nearly no overhead.

Attachments (5)

42313.diff (880 bytes) - added by joostdevalk 6 years ago.
Patch
42313.2.diff (892 bytes) - added by joostdevalk 6 years ago.
Patch v2
42313.3.diff (936 bytes) - added by joostdevalk 6 years ago.
Patch v3, check return value for filter
42313.4.diff (1.5 KB) - added by NathanAtmoz 6 years ago.
Add $x_redirect_by parameter to wp_redirect()
42313.5.diff (1.2 KB) - added by pratikkry 5 years ago.
@since updated to 5.0.3

Download all attachments as: .zip

Change History (23)

@joostdevalk
6 years ago

Patch

@joostdevalk
6 years ago

Patch v2

@joostdevalk
6 years ago

Patch v3, check return value for filter

#1 @SergeyBiryukov
6 years ago

  • Owner set to SergeyBiryukov
  • Status changed from new to accepted

#2 @SergeyBiryukov
6 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 42408:

Canonical: Introduce x_redirect_by filter that allows applications to identify themselves via X-Redirect-By header when they're doing a redirect.

Props joostdevalk.
Fixes #42313.

#3 @SergeyBiryukov
6 years ago

In 42409:

Canonical: After [42408], remove sprintf() call for consistency with Location header.

See #42313.

#4 @johnbillion
6 years ago

  • Keywords has-patch removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

I really like the idea of this header, but I think we can make the implementation even better.

If the header value could be passed as a parameter in addition to via a filter, it would save the need to call add_filter() immediately before calling the redirect function.

Thoughts?

@NathanAtmoz
6 years ago

Add $x_redirect_by parameter to wp_redirect()

#5 @NathanAtmoz
6 years ago

Since the $status can be passed as a parameter and then modified by a filter, it makes sense that $x_redirect_by should be treated the same way.

#6 @SergeyBiryukov
6 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 42633:

Canonical: Add $x_redirect_by parameter to wp_redirect() that allows applications doing the redirect to identify themselves.

This complements the x_redirect_by filter added in [42408].

Props NathanAtmoz, johnbillion.
Fixes #42313.

#7 @johnbillion
6 years ago

  • Keywords needs-patch added; dev-feedback removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

The parameter needs adding to wp_safe_redirect() too.

#8 @johnbillion
6 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 42647:

Canonical: Add $x_redirect_by parameter to wp_safe_redirect().

See [42633] and [42408].

Fixes #42313.

#9 @johnbillion
6 years ago

  • Milestone changed from 5.0 to 5.0.1
  • Resolution fixed deleted
  • Status changed from closed to reopened

@since needs updating

#10 @pento
5 years ago

  • Milestone changed from 5.0.1 to 5.0.2

#11 @pento
5 years ago

  • Milestone changed from 5.0.2 to 5.0.3

@pratikkry
5 years ago

@since updated to 5.0.3

#12 @pratikkry
5 years ago

  • Keywords has-patch added; needs-patch removed

#13 @audrasjb
5 years ago

  • Keywords needs-refresh added

Hi,

5.0.3 is going to be released in a couple of weeks. We are currently sorting the remaining tickets in the milestone. The ticket is sorted in milestone 5.0.3, but requires @since and a commit/backport to the associated branch. That would be great to have a quick refresh.

#14 @audrasjb
5 years ago

@pratikkry thanks for the refresh but the patch you sent seems incomplete ;-)

#15 @audrasjb
5 years ago

  • Keywords needs-refresh removed

Ok sorry @pratikkry I was wrong, your patch is ok.

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


5 years ago

#17 @desrosj
5 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 44386:

Docs: Update since tag for X-Redirect-By header additions.

See [42408-42409], [42633], [42647].

Fixes #42313.

#18 @desrosj
5 years ago

  • Milestone changed from 5.0.3 to 5.1
Note: See TracTickets for help on using tickets.