Commit 45d10c626c for wordpress.org
commit 45d10c626c295c3b078b8d97af9cc60be43394d8
Author: Weston Ruter <weston@xwp.co>
Date: Mon Jan 5 05:58:26 2026 +0000
Code Modernization: HTTP: Use null coalescing operator instead of `isset()` ternaries.
Developed as a subset of https://github.com/WordPress/wordpress-develop/pull/10654
Initially developed in https://github.com/WordPress/wordpress-develop/pull/4886
Follow-up to [61434], [61403], [61433], [61432], [61431], [61430], [61429], [61424], [61404], [61403].
Props costdev, westonruter.
See #58874, #63430.
Built from https://develop.svn.wordpress.org/trunk@61435
git-svn-id: http://core.svn.wordpress.org/trunk@60747 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/class-wp-http-cookie.php b/wp-includes/class-wp-http-cookie.php
index 8f55e4486c..cfdf4da1dd 100644
--- a/wp-includes/class-wp-http-cookie.php
+++ b/wp-includes/class-wp-http-cookie.php
@@ -114,7 +114,7 @@ class WP_Http_Cookie {
if ( isset( $parsed_url['host'] ) ) {
$this->domain = $parsed_url['host'];
}
- $this->path = isset( $parsed_url['path'] ) ? $parsed_url['path'] : '/';
+ $this->path = $parsed_url['path'] ?? '/';
if ( ! str_ends_with( $this->path, '/' ) ) {
$this->path = dirname( $this->path ) . '/';
}
@@ -190,12 +190,12 @@ class WP_Http_Cookie {
// Get details on the URL we're thinking about sending to.
$url = parse_url( $url );
- $url['port'] = isset( $url['port'] ) ? $url['port'] : ( 'https' === $url['scheme'] ? 443 : 80 );
- $url['path'] = isset( $url['path'] ) ? $url['path'] : '/';
+ $url['port'] = $url['port'] ?? ( 'https' === $url['scheme'] ? 443 : 80 );
+ $url['path'] = $url['path'] ?? '/';
// Values to use for comparison against the URL.
- $path = isset( $this->path ) ? $this->path : '/';
- $port = isset( $this->port ) ? $this->port : null;
+ $path = $this->path ?? '/';
+ $port = $this->port ?? null;
$domain = isset( $this->domain ) ? strtolower( $this->domain ) : strtolower( $url['host'] );
if ( false === stripos( $domain, '.' ) ) {
$domain .= '.local';
diff --git a/wp-includes/class-wp-http-ixr-client.php b/wp-includes/class-wp-http-ixr-client.php
index d45ca150eb..41d31ca9d1 100644
--- a/wp-includes/class-wp-http-ixr-client.php
+++ b/wp-includes/class-wp-http-ixr-client.php
@@ -25,7 +25,7 @@ class WP_HTTP_IXR_Client extends IXR_Client {
$bits = parse_url( $server );
$this->scheme = $bits['scheme'];
$this->server = $bits['host'];
- $this->port = isset( $bits['port'] ) ? $bits['port'] : $port;
+ $this->port = $bits['port'] ?? $port;
$this->path = ! empty( $bits['path'] ) ? $bits['path'] : '/';
// Make absolutely sure we have a path.
diff --git a/wp-includes/class-wp-http.php b/wp-includes/class-wp-http.php
index 2e3a9dec22..3b5e2b5636 100644
--- a/wp-includes/class-wp-http.php
+++ b/wp-includes/class-wp-http.php
@@ -692,7 +692,7 @@ class WP_Http {
return array(
'headers' => $response[0],
- 'body' => isset( $response[1] ) ? $response[1] : '',
+ 'body' => $response[1] ?? '',
);
}
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 3555e4be20..8e17ec5911 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.0-alpha-61434';
+$wp_version = '7.0-alpha-61435';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.