8000 Fix HTTP URLs converted to HTTPS in core install by Copilot · Pull Request #6229 · wp-cli/wp-cli · GitHub
[go: up one dir, main page]

Skip to content
Open
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
18 changes: 18 additions & 0 deletions features/class-wp-cli.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,21 @@ Feature: Various utilities for WP-CLI commands
| func |
| proc_open |
| proc_close |

Scenario: HTTP URL scheme clears pre-existing HTTPS server variable
Given an empty directory

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
"""

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
"""
2 changes: 2 additions & 0 deletions php/class-wp-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,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'];
Expand Down
0