-
Notifications
You must be signed in to change notification settings - Fork 3
Description
This is quite similar to #302 from what I can see.
Steps to reproduce:
- Set your front-page to a page in WP settings
- Make sure batcache is enabled
- Request
https://yoursite.com/?=123 - Observe redirect_canonical should redirect to
https://yoursite.com/ - Try to request
https://yoursite.com/ - Observe an infinite redirect to
https://yoursite.com/
When the query string is "malformed", specifically in this case, it's an empty key in ?=123 (no key, value of 123). In these situations $_GET is [], but $_SERVER['QUERY_STRING'] is =123. And, parse_url will be ["query"]=> string(4) "=123"
As you can maybe imagine, this causes issues when the assumption is the query / URL can be re-built from $_GET. One place that makes this assumption is Batcache. Effectively the cache will be stored as if there were no query params (see https://github.com/humanmade/batcache/blob/master/advanced-cache.php#L555, parse_str('=123', $result ) === []).
As redirect_canonical will do a 301 redirect, that redirect will get stored in Batcache against the homepage with no url params cache key. Therefore, the homepage will infinite redirect.