Improve multi-network support in WP-CLI multisite commands #3687

Closed
jeremyfelt opened this Issue Dec 23, 2016 · 6 comments

Projects

None yet

2 participants

@jeremyfelt

This is written using wp super-admin as the main example, though there are probably a handful of things that could be affected depending on the path of action.

Retrieving a list of super admins for the non-primary network is possible with wp super-admin list --url=network2.site.url, but it's not so easy to generate a list of network site URLs. Even though siteurl is network meta, actual network lookup is done based on the domain and path from the wp_site table. It would be more accurate to have something like wp network list --fields=domain,path or something.

It is slightly easier to generate a list of network IDs with something like wp site list --field=site_id | sort -n | uniq. It's kind of hacky, but could be piped to wp super-admin remove user --network_id=%.

It looks like network was initially planned as an option for wp super-admin in #819, but wasn't implemented due to how uncommon multi-network installations are.

All of that leads me to wonder whether it makes sense to:

  • Create a PR to add support for network_id to wp super-admin.
  • Create a PR to start adding support for wp network and subcommands.
  • Create a package (maybe with parts of wp-multi-network) for those unlikely multi-networkers.

One caveat to any of these approaches is that the nicer multi-network stuff in WordPress core has only been available in the last few releases. I guess that could be one argument toward making a package and declaring support for WP 4.6+.

Thoughts?

@danielbachhuber
Member

Thoughts?

There's a lot going on here :)

I don't think adding a --network_id=<id> argument to wp super-admin makes sense. The established paradigm for running a command against a given site (including the primary site for a network) is the --url=<url> global parameter.

I do see an argument for making it easier to filter wp site list to only display the primary site for each network. You could then do something like wp site list --network-primary --field=url and pass to xargs.

One caveat to any of these approaches is that the nicer multi-network stuff in WordPress core has only been available in the last few releases. I guess that could be one argument toward making a package and declaring support for WP 4.6+.

What network features aren't covered in existing WP-CLI commands?

@danielbachhuber
Member

@jeremyfelt Anything further you want to discuss here?

@jeremyfelt

Ooph, reading back... that was a dump of a request. Thanks for parsing it. :)

I do see an argument for making it easier to filter wp site list to only display the primary site for each network. You could then do something like wp site list --network-primary --field=url and pass to xargs.

I think this is probably the right idea.

WordPress doesn't really track the relationship between a network and its primary site. The best way to do it now is to compare the domain and path of each row from wp_site with the matching record in wp_blogs. Right now this would mean an additional query per network to generate that list.

Is that too hacky for something to build into WP-CLI?

@danielbachhuber
Member

No, I think this would be fine.

@danielbachhuber
Member

WordPress doesn't really track the relationship between a network and its primary site. The best way to do it now is to compare the domain and path of each row from wp_site with the matching record in wp_blogs. Right now this would mean an additional query per network to generate that list.

Could you describe in greater detail what this logic should be? I'd like to get this flag either implemented or punted.

@danielbachhuber
Member

We can revisit this when there's some momentum around the issue.

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