10up / MU-Migration

This WP-CLI plugin makes the process of moving sites from single WordPress sites to a Multisite instance (or vice-versa) much easier. It exports everything into a zip package which can be used to automatically import it within the desired Multisite installation.
MIT License
329 stars 47 forks source link

Cloning a subsite using export/import --new_url affects the source subsite domain #67

Open ppiotr3k opened 5 years ago

ppiotr3k commented 5 years ago

Describe the bug

When cloning a subsite in a multisite install using export/import, the source subsite domain is updated to the target subsite URL.

Steps to Reproduce

  1. wp mu-migration export all --blog_id=8 /tmp/blog_template.zip --themes --plugins --uploads
  2. wp mu-migration import all /tmp/blog_template.zip --new_url="https://mynew.url"
  3. _blogid=8 gets https://mynew.url as domain in DB

Expected behavior

source subsite is not affected by the creation of a new subsite when using export/import with --new_url

nicholasio commented 5 years ago

@ppiotr3k Are you importing the exported site in the same subsite? If so this is very likely an unhandled edge case, since when the search-replace takes place to replace the URL, it affects both subsites given they both have the same URL/Domain at the time search-replace is run and since search-replace is performed with the --network flag it catches both sites. You'd have the same issue if you didn't provide --new_url and tried to run search-replace afterwards with the --network flag.

We can probably solve this by restricting the search-replace to the imported subsite and handling the search-replace of the necessary global tables manually.

ppiotr3k commented 5 years ago

@nicholasio I confirm this is an export/import in the same WordPress multisite deployment. The export/import features are used as a cloning operation, providing a new URL for the target during import.

Also, I haven't noticed previously, but indeed the URL is replaced in the source site in other places as well, with the target site URL, as explained in your possible cause analysis :clap:

jmtornetta commented 3 years ago

Confirmed this is an issue for me as well.

jmtornetta commented 3 years ago

For others following, my workaround was to use wp-cli to change the site address to the "new site address" prior to exporting. Once the export is done, the script changes the site address back. Then, upon importing, you don't need to specify a new address.

I think I've mostly finished with the bash script, if anyone is interested lmk and I'll finish it up and provide.

vdwijngaert commented 2 years ago

I think I've mostly finished with the bash script, if anyone is interested lmk and I'll finish it up and provide.

Hey @jmtornetta, still got that script somewhere? :)