Describe the bug
On a non-multisite install running a search causes an infinite redirect loop.
(This issue replaces #780 which misidentified the root cause for the loop.)
To Reproduce
Steps to reproduce the behavior:
- Run a search either with the standard /?s=foo or /search/foo
- See the browser failing due to an endless redirect loop.
Expected behaviour
see search results
Actual behaviour
endless redirect loop
Additional context
This check:
|
if ( set_url_scheme( $current, 'https' ) === set_url_scheme( $target, 'https' ) ) { |
never succeeds due to the current_url helper function returning a wrong value for a search query. This happens because it behaves differently in a non-multisite setup.
The reason it actually does return the wrong value is due to amnesty_maybe_override_search_uri being hooked into home_url which changes any search query URL into the search page without the query.
The immediate fix for the endless loop here seems to be to drop the different behavior on non-multisite here:
|
if ( ! is_multisite() ) { |
|
$home = home_url( $path, 'https' ); |
|
|
|
return empty( $query ) ? $home : add_query_arg( $query, $home ); |
|
} |
But I'd also question what the hooking into home_url here does and if it really is needed since that also seems to be wrong.
Describe the bug
On a non-multisite install running a search causes an infinite redirect loop.
(This issue replaces #780 which misidentified the root cause for the loop.)
To Reproduce
Steps to reproduce the behavior:
Expected behaviour
see search results
Actual behaviour
endless redirect loop
Additional context
This check:
humanity-theme/wp-content/themes/humanity-theme/includes/features/search/class-search-filters.php
Line 96 in bdfcaed
never succeeds due to the
current_urlhelper function returning a wrong value for a search query. This happens because it behaves differently in a non-multisite setup.The reason it actually does return the wrong value is due to
amnesty_maybe_override_search_uribeing hooked intohome_urlwhich changes any search query URL into the search page without the query.The immediate fix for the endless loop here seems to be to drop the different behavior on non-multisite here:
humanity-theme/wp-content/themes/humanity-theme/includes/helpers/site.php
Lines 27 to 31 in bdfcaed
But I'd also question what the hooking into
home_urlhere does and if it really is needed since that also seems to be wrong.