From d12ad28594ce55c0c6d914322dd719c7b691bd33 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 16:12:50 +0000 Subject: [PATCH 1/3] Initial plan From baffd05d41784654eb797da23e25e5540a44d450 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 16:18:24 +0000 Subject: [PATCH 2/3] Fix HTTP to HTTPS conversion in wp core install --prompt - Modified WP_CLI::set_url_params() to unset $_SERVER['HTTPS'] when scheme is not HTTPS - Added tests to verify HTTP and HTTPS URL schemes are preserved correctly - All tests passing Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/class-wp-cli.feature | 18 ++++++++++++++++++ php/class-wp-cli.php | 2 ++ 2 files changed, 20 insertions(+) diff --git a/features/class-wp-cli.feature b/features/class-wp-cli.feature index 07c01b8010..a74202b199 100644 --- a/features/class-wp-cli.feature +++ b/features/class-wp-cli.feature @@ -13,3 +13,21 @@ Feature: Various utilities for WP-CLI commands | func | | proc_open | | proc_close | + + Scenario: HTTP URL scheme does not set HTTPS server variable + Given an empty directory + + When I run `wp --skip-wordpress eval 'WP_CLI::set_url("http://example.com"); echo isset($_SERVER["HTTPS"]) ? "set" : "not set";'` + Then STDOUT should be: + """ + not set + """ + + Scenario: HTTPS URL scheme sets HTTPS server variable + Given an empty directory + + When I run `wp --skip-wordpress eval 'WP_CLI::set_url("https://example.com"); echo isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] === "on" ? "on" : "off";'` + Then STDOUT should be: + """ + on + """ diff --git a/php/class-wp-cli.php b/php/class-wp-cli.php index faf7f59153..704917e5ef 100644 --- a/php/class-wp-cli.php +++ b/php/class-wp-cli.php @@ -137,6 +137,8 @@ private static function set_url_params( $url_parts ) { if ( isset( $url_parts['host'] ) ) { if ( isset( $url_parts['scheme'] ) && 'https' === strtolower( $url_parts['scheme'] ) ) { $_SERVER['HTTPS'] = 'on'; + } else { + unset( $_SERVER['HTTPS'] ); } $_SERVER['HTTP_HOST'] = $url_parts['host']; From 722f7b115cb850b9bc20d924422332013abdb2e1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 19:26:30 +0000 Subject: [PATCH 3/3] Improve test to validate regression with pre-existing HTTPS variable The test now properly simulates the bug scenario by pre-populating $_SERVER['HTTPS'] before calling set_url() with an HTTP URL. This ensures the test would fail without the unset() fix, properly guarding against regression. Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/class-wp-cli.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/class-wp-cli.feature b/features/class-wp-cli.feature index a74202b199..cd5786dc56 100644 --- a/features/class-wp-cli.feature +++ b/features/class-wp-cli.feature @@ -14,10 +14,10 @@ Feature: Various utilities for WP-CLI commands | proc_open | | proc_close | - Scenario: HTTP URL scheme does not set HTTPS server variable + Scenario: HTTP URL scheme clears pre-existing HTTPS server variable Given an empty directory - When I run `wp --skip-wordpress eval 'WP_CLI::set_url("http://example.com"); echo isset($_SERVER["HTTPS"]) ? "set" : "not set";'` + When I run `wp --skip-wordpress eval '$_SERVER["HTTPS"] = "on"; WP_CLI::set_url("http://example.com"); echo isset($_SERVER["HTTPS"]) ? "set" : "not set";'` Then STDOUT should be: """ not set