Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/InitOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,13 @@ public function maybe_exclude_pageview( $options = [] ) {
/**
* This a seam for @see add_query_arg() to be mocked in unit tests.
*
* @since 2.6.2 Uses add_query_arg( [] ) instead of add_query_arg( null, null ): both return the current request URI,
* but the latter uses null as an array offset, which is deprecated since PHP 8.5.
*
* @codeCoverageIgnore
*/
protected function get_current_request() {
return add_query_arg( null, null );
return add_query_arg( [] );
}

/**
Expand Down
10 changes: 6 additions & 4 deletions src/Integrations/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ public function maybe_add_hidden_input_to_search_form( $form ) {
*
* The scheme and host are taken from the configured home_url() so the referrer stays correct behind reverse
* proxies (where is_ssl() can be unreliable). The path and query come straight from the current request
* (add_query_arg( null, null )), which already includes any subdirectory the site is installed in. Passing that
* request URI through home_url() instead would prepend the home path a second time, duplicating the subdirectory
* on subdirectory installs (e.g. https://example.com/dev/dev/...).
* (add_query_arg( [] )), which already includes any subdirectory the site is installed in. Passing that request
* URI through home_url() instead would prepend the home path a second time, duplicating the subdirectory on
* subdirectory installs (e.g. https://example.com/dev/dev/...).
*
* add_query_arg( null, null ) returns the same, but uses null as an array offset, which is deprecated since PHP 8.5.
*
* @return string The sanitized referrer URL or an empty string if unavailable.
*
Expand All @@ -76,7 +78,7 @@ private function get_referrer() {
return '';
}

$referrer = esc_url( $scheme . '://' . $host . $port . add_query_arg( null, null ) );
$referrer = esc_url( $scheme . '://' . $host . $port . add_query_arg( [] ) );

if ( ! $referrer ) {
$referrer = '';
Expand Down
Loading