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

Allows command line argument to define postmeta fields that contain user ids (Fixes #48) #50

Closed andyzito closed 6 years ago

andyzito commented 6 years ago

The command line argument uid_fields will tell MU-Migration that there are postmeta fields containing user ids, and that those fields will need to be included in user id mapping on import.

This basically just extends the existing functionality around WooCommerce customer field to include an arbitrary set of postmeta fields. The WooCommerce field is automatically added to the list of user id fields if WooCommerce is active.

Example:

wp mu-migration import all mysite.zip --new_url=example.com/mysite --uid_fields='_content_audit_owner,_another_postmeta_userid_field'

Manual testing indicates that this works. I'd like to develop unit tests, but haven't gotten to it yet.

andyzito commented 6 years ago

Both good catches on your suggested changes. I'll make them soon -- in the meantime, re: the tests failing, I note that Travis says they didn't fail but errored due to a composer command erroring. That seems unlikely to be caused by the changes here (didn't see it locally, at least). Have you tried re-running the tests?

nicholasio commented 6 years ago

@azito122 Tests are passing locally. Could you also come up with a test for this new feature? maybe just add some random meta with user ids and have MU-Migration replace them.

andyzito commented 6 years ago

Refactored based on maintainer feedback above. Unit tests are in the works.

andyzito commented 6 years ago

@nicholasio FYI I think your Travis builds are dead. Even master is failing when I trigger a build from our fork. Not sure what exactly is broken but you can see the error in the build for this pull request, or, I bet, if you trigger a master build on your own Travis.

andyzito commented 6 years ago

Update: seems to be a problem with wp-cli version 2.0.0 and 2.0.1. At least, when I downgraded to 1.5.1 it solved the problem.

andyzito commented 6 years ago

The Travis builds are exploding. In addition to to the problem with wp-cli, I found that to get the builds to run I had to clear the Travis cache for that branch in between builds.

In terms of the functionality related to this pull request, here are the tests passing, with code matching what's in this branch now. I added the uid_fields test to the existing update authors test.

nicholasio commented 6 years ago

@azito122 Let's get the Travis fixed first before merging this. But it looks good overall!

andyzito commented 6 years ago

Rebased on current master (travis fixes)

nicholasio commented 6 years ago

Hmm, travis is still failing on this one. Any idea why?

andyzito commented 6 years ago

Looks like travis is passing now.

nicholasio commented 6 years ago

Yeah, I cleared Travis cache and it seems to have fixed.