From f592a97cded594988afacd41fdad0417bc2a7808 Mon Sep 17 00:00:00 2001 From: Daan van den Bergh <18595395+Dan0sz@users.noreply.github.com> Date: Tue, 29 Sep 2026 16:48:54 +0200 Subject: [PATCH 1/2] Fix PHP 8.5 deprecation notices - Use add_query_arg( [] ) instead of add_query_arg( null, null ) to get the current request URI. Both return the same, but the latter uses null as an array offset, which is deprecated since PHP 8.5 ("Using null as an array offset is deprecated" in wp-includes/functions.php), shown on every page with a search form when Search Queries tracking is enabled. - Only call curl_close() on PHP < 8.0 in the bundled Guzzle, like Guzzle 7.10 does: it has had no effect since PHP 8.0 and is deprecated since PHP 8.5, which showed on every API request. --- src/Client/lib/Lib/GuzzleHttp/Handler/CurlFactory.php | 8 ++++++-- .../lib/Lib/GuzzleHttp/Handler/CurlMultiHandler.php | 4 +++- src/InitOptions.php | 5 ++++- src/Integrations/Search.php | 10 ++++++---- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/Client/lib/Lib/GuzzleHttp/Handler/CurlFactory.php b/src/Client/lib/Lib/GuzzleHttp/Handler/CurlFactory.php index 1a862051..c8acd9b2 100644 --- a/src/Client/lib/Lib/GuzzleHttp/Handler/CurlFactory.php +++ b/src/Client/lib/Lib/GuzzleHttp/Handler/CurlFactory.php @@ -78,7 +78,9 @@ public function release(EasyHandle $easy): void unset($easy->handle); if (\count($this->handles) >= $this->maxHandles) { - \curl_close($resource); + if (\PHP_VERSION_ID < 80000) { + \curl_close($resource); + } } else { // Remove all callback functions as they can hold onto references // and are not cleaned up by curl_reset. Using curl_setopt_array @@ -631,7 +633,9 @@ private function createHeaderFn(EasyHandle $easy): callable public function __destruct() { foreach ($this->handles as $id => $handle) { - \curl_close($handle); + if (\PHP_VERSION_ID < 80000) { + \curl_close($handle); + } unset($this->handles[$id]); } } diff --git a/src/Client/lib/Lib/GuzzleHttp/Handler/CurlMultiHandler.php b/src/Client/lib/Lib/GuzzleHttp/Handler/CurlMultiHandler.php index ea01c61b..8834fbfc 100644 --- a/src/Client/lib/Lib/GuzzleHttp/Handler/CurlMultiHandler.php +++ b/src/Client/lib/Lib/GuzzleHttp/Handler/CurlMultiHandler.php @@ -223,7 +223,9 @@ private function cancel($id): bool $handle = $this->handles[$id]['easy']->handle; unset($this->delays[$id], $this->handles[$id]); \curl_multi_remove_handle($this->_mh, $handle); - \curl_close($handle); + if (\PHP_VERSION_ID < 80000) { + \curl_close($handle); + } return true; } diff --git a/src/InitOptions.php b/src/InitOptions.php index 8a108fc8..e6f0de70 100644 --- a/src/InitOptions.php +++ b/src/InitOptions.php @@ -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( [] ); } /** diff --git a/src/Integrations/Search.php b/src/Integrations/Search.php index 4a6304bd..249ce406 100644 --- a/src/Integrations/Search.php +++ b/src/Integrations/Search.php @@ -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. * @@ -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 = ''; From 4cc39ba62cd49a86d92b70a8e824c1d6a8cdba02 Mon Sep 17 00:00:00 2001 From: Daan van den Bergh <18595395+Dan0sz@users.noreply.github.com> Date: Tue, 29 Sep 2026 17:16:19 +0200 Subject: [PATCH 2/2] Revert the curl_close() change in the bundled Guzzle src/Client/lib/Lib is generated by Mozart, so hand edits are overwritten on the next run. The curl_close() deprecation is fixed by updating Guzzle instead, in a separate PR. --- src/Client/lib/Lib/GuzzleHttp/Handler/CurlFactory.php | 8 ++------ .../lib/Lib/GuzzleHttp/Handler/CurlMultiHandler.php | 4 +--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Client/lib/Lib/GuzzleHttp/Handler/CurlFactory.php b/src/Client/lib/Lib/GuzzleHttp/Handler/CurlFactory.php index c8acd9b2..1a862051 100644 --- a/src/Client/lib/Lib/GuzzleHttp/Handler/CurlFactory.php +++ b/src/Client/lib/Lib/GuzzleHttp/Handler/CurlFactory.php @@ -78,9 +78,7 @@ public function release(EasyHandle $easy): void unset($easy->handle); if (\count($this->handles) >= $this->maxHandles) { - if (\PHP_VERSION_ID < 80000) { - \curl_close($resource); - } + \curl_close($resource); } else { // Remove all callback functions as they can hold onto references // and are not cleaned up by curl_reset. Using curl_setopt_array @@ -633,9 +631,7 @@ private function createHeaderFn(EasyHandle $easy): callable public function __destruct() { foreach ($this->handles as $id => $handle) { - if (\PHP_VERSION_ID < 80000) { - \curl_close($handle); - } + \curl_close($handle); unset($this->handles[$id]); } } diff --git a/src/Client/lib/Lib/GuzzleHttp/Handler/CurlMultiHandler.php b/src/Client/lib/Lib/GuzzleHttp/Handler/CurlMultiHandler.php index 8834fbfc..ea01c61b 100644 --- a/src/Client/lib/Lib/GuzzleHttp/Handler/CurlMultiHandler.php +++ b/src/Client/lib/Lib/GuzzleHttp/Handler/CurlMultiHandler.php @@ -223,9 +223,7 @@ private function cancel($id): bool $handle = $this->handles[$id]['easy']->handle; unset($this->delays[$id], $this->handles[$id]); \curl_multi_remove_handle($this->_mh, $handle); - if (\PHP_VERSION_ID < 80000) { - \curl_close($handle); - } + \curl_close($handle); return true; }