Fix HTTP URLs converted to HTTPS in core install#6229
Draft
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
- 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>
Copilot
AI
changed the title
[WIP] Fix URL scheme when using --prompt with wp core install
Fix HTTP URLs converted to HTTPS in core install
Feb 4, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR ensures that wp core install respects the explicitly provided URL scheme instead of incorrectly forcing HTTPS when $_SERVER['HTTPS'] is already set, and adds coverage around WP_CLI::set_url()’s handling of HTTP/HTTPS.
Changes:
- Update
WP_CLI::set_url_params()to explicitly unset$_SERVER['HTTPS']when the parsed URL scheme is not HTTPS, preventing unwanted HTTPS enforcement. - Extend
features/class-wp-cli.featurewith scenarios checking howWP_CLI::set_url()affects the$_SERVER['HTTPS']variable for HTTP and HTTPS URLs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| php/class-wp-cli.php | Adjusts URL context initialization to clear $_SERVER['HTTPS'] for non-HTTPS schemes so WordPress core URL detection honors the provided scheme. |
| features/class-wp-cli.feature | Adds Behat scenarios intended to verify that WP_CLI::set_url() does not set HTTPS for HTTP URLs and correctly sets it for HTTPS URLs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix for HTTP to HTTPS conversion issue in wp core install --prompt
Root Cause
When running
wp core install --promptwith an HTTP URL, the URL is incorrectly converted to HTTPS in the database. The issue is in theWP_CLI::set_url_params()method inphp/class-wp-cli.php.When the URL scheme is 'https', it correctly sets
$_SERVER['HTTPS'] = 'on', but when the scheme is 'http', it doesn't explicitly unset or handle$_SERVER['HTTPS']. If this variable is already set in the environment, WordPress'swp_guess_url()function will detect it and use HTTPS for the site URL.Minimal Change Plan
php/class-wp-cli.phpset_url_params()to properly handle HTTP scheme by unsetting $_SERVER['HTTPS']Changes Made
php/class-wp-cli.php (3 lines changed)
elseclause to unset$_SERVER['HTTPS']when scheme is not HTTPSwp_guess_url()correctly detects HTTP URLsfeatures/class-wp-cli.feature (18 lines added)
$_SERVER['HTTPS']to test the actual bug scenarioTest Results
Security Summary
No security vulnerabilities were discovered or introduced by this change.
Original prompt
This section details on the original issue you should resolve
<issue_title>Using --prompt on 'wp core install' creates a https:// instead of http:// URL</issue_title>
<issue_description>## Bug Report
Describe the current, buggy behavior
When running
wp core install --promptand use an URL with http:// at the beginning, the URL will be changed to https:// in the database.Describe how other contributors can replicate this bug
wp core install --promptDescribe what you would expect as the correct outcome
When stating an URL with http://, it should be added as http:// to the database and not be converted to https://.
Let us know what environment you are running this on
Also running MAMP Pro 6.6 on macOS Monterey (12.3).
Provide additional context/Screenshots
See this Twitter thread, where @pixolin kindly tested this on his machine (different setup, but same problem): https://twitter.com/pixolin/status/1517132670899081216
</issue_description>
Comments on the Issue (you are @copilot in this section)
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.