Skip to content

Passing an invalid multisite subdirectory defaults to subsite 1 #5812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gamebits opened this issue Sep 13, 2019 · 1 comment
Open

Passing an invalid multisite subdirectory defaults to subsite 1 #5812

gamebits opened this issue Sep 13, 2019 · 1 comment

Comments

@gamebits
Copy link

Bug Report

When using commands such as wp option update siteurl on a multisite, passing a --url parameter of a non-existent domain or subdomain will return an error. But passing a --url parameter of a non-existent subdirectory will not return an error and will instead apply the command to subsite 1. This means that a typo in a command targeting subsite 2 will inadvertently change subsite 1, which can cause a site to break.

Describe how other contributors can replicate this bug

Here is an example log where the subdirectory is info but I omit the o.

$ wp site list
+---------+---------------------+---------------------+------------------------+
| blog_id | url                 | last_updated        | registered             |
+---------+---------------------+---------------------+------------------------+
| 1       | https://xyzzy-com-d | 2019-08-26 16:47:12 | 2019-06-25 15:44:38    |
|         | evelop.wp-cli.net/  |                     |                        |
| 2       | https://xyzzy-com-d | 2019-07-15 17:45:07 | 2019-06-25 22:45:29    |
|         | evelop.wp-cli.net/i |                     |                        |
|         | nfo/                |                     |                        |
+---------+---------------------+---------------------+------------------------+
$ wp option get siteurl --url=example.com
Error: Site 'example.com' not found. Verify `--url=` matches an existing site.
$ wp option update siteurl https://example.com --url=example.com
Error: Site 'example.com' not found. Verify `--url=` matches an existing site.
$ wp option get siteurl --url=xyzzy-com-develop.wp-cli.net/info/
https://xyzzy-com-develop.wp-cli.net/info
$ wp option get siteurl --url=xyzzy-com-develop.wp-cli.net/inf  
https://xyzzy-com-develop.wp-cli.net
$ wp option update siteurl example.com --url=xyzzy-com-develop.wp-cli.net/inf  
Success: Value passed for 'siteurl' option is unchanged.
$ wp option update siteurl https://example.com --url=xyzzy-com-develop.wp-cli.net/inf  
Success: Updated 'siteurl' option.
$ wp site list
+---------+---------------------+---------------------+------------------------+
| blog_id | url                 | last_updated        | registered             |
+---------+---------------------+---------------------+------------------------+
| 1       | https://example.com | 2019-08-26 16:47:12 | 2019-06-25 15:44:38    |
|         | /                   |                     |                        |
| 2       | https://xyzzy-com-d | 2019-07-15 17:45:07 | 2019-06-25 22:45:29    |
|         | evelop.wp-cli.net/i |                     |                        |
|         | nfo/                |                     |                        |
+---------+---------------------+---------------------+------------------------+
$ wp option update siteurl https://xyzzy-com-develop.wp-cli.net/
Success: Updated 'siteurl' option.
$ wp site list
+---------+---------------------+---------------------+------------------------+
| blog_id | url                 | last_updated        | registered             |
+---------+---------------------+---------------------+------------------------+
| 1       | https://xyzzy-com-d | 2019-08-26 16:47:12 | 2019-06-25 15:44:38    |
|         | evelop.wp-cli.net/  |                     |                        |
| 2       | https://xyzzy-com-d | 2019-07-15 17:45:07 | 2019-06-25 22:45:29    |
|         | evelop.wp-cli.net/i |                     |                        |
|         | nfo/                |                     |                        |
+---------+---------------------+---------------------+------------------------+

Desired behavior

The command

wp option update siteurl https://example.com --url=xyzzy-com-develop.wp-cli.net/inf

would return

Error: Site 'xyzzy-com-develop.wp-cli.net/inf' not found. Verify `--url=` matches an existing site.

Environment

I have replicated this experience in two environments:

MAMP

OS:	Darwin 17.7.0 Darwin Kernel Version 17.7.0: Sun Jun  2 20:31:42 PDT 2019; root:xnu-4570.71.46~1/RELEASE_X86_64 x86_64
Shell:	/bin/bash
PHP binary:	/Applications/MAMP/bin/php/php7.3.1/bin/php
PHP version:	7.3.1
php.ini used:	/Applications/MAMP/bin/php/php7.3.1/conf/php.ini
WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	/Users/kgagne/Sites/wp
WP-CLI packages dir:	
WP-CLI global config:	
WP-CLI project config:	
WP-CLI version:	2.3.0

And WPVIP:

OS:	Linux 4.9.0-9-amd64 wp-cli/entity-command#1 SMP Debian 4.9.168-1+deb9u2 (2019-05-13) x86_64
Shell:	/bin/bash
PHP binary:	/root/roles/nginx-php/usr/local/php7.3/bin.stretch/php
PHP version:	7.3.9
php.ini used:	/usr/local/php7.3/conf/php.ini
WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	/home/vipdev
WP-CLI packages dir:	
WP-CLI global config:	
WP-CLI project config:	
WP-CLI version:	2.2.0
@danielbachhuber danielbachhuber transferred this issue from wp-cli/entity-command Jul 13, 2023
@danielbachhuber
Copy link
Member

Thanks for the report, @gamebits.

I agree — this behavior is pretty confusing. Unfortunately, I'm not sure if there's an easy solution for this.

On the web, an invalid subdirectory URL is ambiguous: is it a missing site or a missing page?

image image

Open to ideas on how to solve this. I'm not sure there's a clean solution though, and we'll need a clean solution in order to change the behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants