Proper CLI context for individual blogs in multisite
Let's say I have a multisite installation with multiple blogs (subdomain installs). the main blog in the network is www.example.com. Now, I have another blog in the network at test.example.com. On this blog, I have the plugin called XYZ and this plugin adds WP CLI command xyz. This plugin XYZ is only active on test.example.com. So, in WP CLI I try to run the command:
wp xyz --url=test.example.com
But, I get the error that xyz is not found. I have used --url to specify the blog in the network, yet this is not working, so the CLI is not using proper blog context at all. Now, if I activate the XYZ as a network-wide plugin, the CLI code with URL works, so whatever is loaded as a network plugin, or even as a plugin on the main blog in the network is used by CLI.
CLI doesn’t actually load the context of the blog targeted by –url, it just uses switch_blog from what I can see. is this correct? If yes, what is the point of the --url if it doesn't really work inside the context of the blog you want? Is this a bug in the CLI design, or is it intended behavior (again, what's the point of having broken support for blogs in the network, if everything depends on the network-wide plugins)?
Regards, Milan
Thanks for the report, @dev4press
When you use --url=test.example.com, WP-CLI should call WP_CLI::set_url(), which should pull the active_plugins for that site and load them as you expect.
Were you able to track down any further details about this issue? Which versions of WP-CLI does it reproduce with?
I gave up using WP-CLI for anything site-related inside the network installation. Too many things are not working as expected. I am not sure what would be a good solution for this, but right now is usable for some things but very problematic for many advanced stuff.
Sounds good! Happy to help figure out what the issue might be if you're able to debug further.
Why is this issue closed?
Why is this issue closed?
Our issue tracker is for bugs with steps to reproduce the situation with a generic WordPress install.
If you need help debugging something in your environment, feel free to stop by #cli in WordPress.org Slack and someone may be able to give you pointers.