WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#16887 closed enhancement (worksforme)

Increase the default number of maximum redirects to 20

Reported by: hakre Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: HTTP API Keywords:
Focuses: Cc:

Description

The default number of maximum redirects in the diverse HTTP implementations in wordpress are hard-encoded to 5.

I suggest to change that hardencoding to 20.

That's PHP's hardencoded value as well.

I could not find any information in wordpress so far, why 5 was hardencoded.

Change History (8)

comment:1 hakre3 years ago

Related: #11557

comment:2 dd323 years ago

  • Component changed from General to HTTP

5 does seem a little low with some of the links i've seen lately, Redirecting 3~5 times before landing at the new location. More commonly happens with "larger" sites

comment:3 sivel 3 years ago

20 sounds absolutely absurd. I think 5 is still OK, but if we increase it, I say 7 perhaps. If we go any higher I think it may become important to start looking for redirection loops to prevent unnecessary location following.

comment:4 dd323 years ago

20 sounds absolutely absurd.

I do agree, 10 seems like an upper limit to consider, but even that seems too high.

I think it may become important to start looking for redirection loops

That came into my head as well, break if the location being requested has already been requested with the same params? I can see that causing issue though for someone, ie: /node/something/ => /create/something/ => /node/something/ - not that I'd ever recommend someone do that, but I can see someone implementing that

Setting an upper soft limit (ie. changeable upon request) of a sane value sounds better to me; 7 is a nice human-random number in the right range, but still has the 'low' look to it.

The downside to having the redirects too large is the latency in requests, it can easily add up to 1s waiting for a HTTP response right now, and thats on a reasonable connection (200ms is not unreasonable for a single request, anything up to 500ms should be assumed to be a reasonable redirection response IMO), so going too high can introduce perceived slowness (even when it's not WordPress's fault that a plugin has made a request for a infinite-redirecting document)

comment:5 hakre3 years ago

Just for some feedback: I opted for 20 because it's the PHP default. Probably users expect it, probably the PHP folks made their mind about, so I thought it's not that bad to stick with the default (before deferring with any details).

comment:6 hakre3 years ago

  • Resolution set to worksforme
  • Status changed from new to closed

I can now imagine where the 5 is coming from, just ran over this:

Note: previous versions of this specification recommended a
      maximum of five redirections. Content developers should be aware
      that there might be clients that implement such a fixed
      limitation.

from: RFC 2616; 10.3 Redirection 3xx

Looks like 5 has been chosen for a reason. As long as there is no really reason to change this I consider to close this as worksforme as I did not run into any problems and was merely looking for a documented decision-base for the number of redirects - which I found now.

If someone else considers change of the value should feel free to re-open.

Last edited 3 years ago by hakre (previous) (diff)

comment:7 hakre3 years ago

  • Type changed from feature request to enhancement

comment:8 dd323 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.