MU-Migration icon indicating copy to clipboard operation
MU-Migration copied to clipboard

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

Open ppiotr3k opened this issue 6 years ago • 5 comments

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. blog_id=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

ppiotr3k avatar Nov 08 '19 12:11 ppiotr3k

@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.

nicholasio avatar Nov 08 '19 14:11 nicholasio

@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:

ppiotr3k avatar Nov 18 '19 14:11 ppiotr3k

Confirmed this is an issue for me as well.

jmtornetta avatar Apr 17 '21 23:04 jmtornetta

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.

jmtornetta avatar Apr 25 '21 21:04 jmtornetta

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? :)

vdwijngaert avatar Oct 20 '22 07:10 vdwijngaert