Validate --url parameter, warn on malformed values, and verify multisite site existence#6154
Validate --url parameter, warn on malformed values, and verify multisite site existence#6154
Conversation
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
|
@copilot Scheme validation is nice, but most importantly we'll want to check whether a site with the current URL actually exists in the multisite. We can do that in |
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Added proactive multisite URL validation in |
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Description
Malformed
--urlvalues likehttp:/example.com(missing slash) are silently ignored. PHP'sparse_url()interprets this asscheme='http', path='/example.com'with no host, causing$_SERVER['HTTP_HOST']to remain unset. In multisite, this defaults to the primary site.This PR implements two-layered validation to address the issue:
Changes
php/class-wp-cli.php
WP_CLI::set_url()to check for missing host and invalid schemesphp/WP_CLI/Runner.php
validate_multisite_url()method to check if site exists in multisiteload_wordpress()after WordPress is fully loadedget_sites()WordPress API for clean, reliable site lookupfeatures/flags.feature
Example
Validation catches:
http:/example.com(warning)htp://example.com(warning)invalid.example.com(error after WordPress loads)example.com→http://example.comFixes #5716
Original prompt
💡 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.