Skip to content
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

--url and --all-tables being used together in multisite #120

Open
1 task done
rebeccahum opened this issue Apr 24, 2019 · 1 comment
Open
1 task done

--url and --all-tables being used together in multisite #120

rebeccahum opened this issue Apr 24, 2019 · 1 comment

Comments

@rebeccahum
Copy link

rebeccahum commented Apr 24, 2019

Feature Request

Describe your use case and the problem you are facing

In a multisite environment, passing in both --url and --all-tables together ends up searching and replacing on all tables instead of the associated tables in the subsite passed in through the --url flag.

Describe the solution you'd like

A) It would be nice to warn the user before executing that passing in --url with --all-tables in a multisite environment will ignore the --url parameter and all tables in the multisite will be affected
Or..
B) Perform the search-replace on only the associated tables of the subsite passed in via --url.

@rebeccahum rebeccahum changed the title Throw warning if --url and --all-tables are used together --url and --all-tables being used together in multisite Apr 24, 2019
@schlessera
Copy link
Member

schlessera commented May 2, 2019

I don't think the current behavior is wrong. It is not that --url is being ignored. It is still being used to run a specific URL through WP's "router" to see where we end up. And then, wherever that might be, we run the replace on --all-tables.

The --url flag does not actually state that it has any effect on the search-replace. Also, depending on the site setup, the --url flag could even have an effect on what "network" to run the search-replace, not only what individual site.

As an example of where your proposed solution B) would be problematic, think about when you migrate an entire network. At one point, the URLs don't match up with what is stored in the database, and you normally then use --url to override the URL that is being used for the root site, but still want to do an operation over the entire network.

That leaves us with the question of whether we should actually throw a warning like you proposed in A).

This is what help tells us right now:

[--network]
  Search/replace through all the tables registered to $wpdb in a
  multisite install.

[--all-tables-with-prefix]
  Enable replacement on any tables that match the table prefix even if
  not registered on $wpdb.

[--all-tables]
  Enable replacement on ALL tables in the database, regardless of the
  prefix, and even if not registered on $wpdb. Overrides --network
  and --all-tables-with-prefix.

I don't think there is a perfect fit within these for what you actually expect the behavior to be, but this is because there is no knowledge available about what the proper tables to affect should be. If plugins register custom tables, we cannot possibly know whether they are part of a subsite, central to the entire network, or anything else really. The closest would be --all-tables-with-prefix, but there's no guarantee you're not missing a table that does not use the prefix but would be part of that subsite.

In that context, does it make sense to provide a warning when you use --all-tables? You specifically state that you want to run the operation on ALL tables in the database after all...

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