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

Command for changing the domain of a site #159

Open
johnbillion opened this issue Feb 17, 2021 · 2 comments
Open

Command for changing the domain of a site #159

johnbillion opened this issue Feb 17, 2021 · 2 comments

Comments

@johnbillion
Copy link

johnbillion commented Feb 17, 2021

Describe your use case and the problem you are facing

As discussed during the WP-CLI office hours chat today (discussion starts here), several people expressed interest in a command that specifically handles changing the domain name of a site. Currently wp search-replace can be used for this but there are pitfalls, for example if the search value is a substring of the replacement then the command cannot be repeated without causing further unwanted replacements, and being able to reliably replace all instances of full URLs.

Related links:

Describe the solution you'd like

Introduce a dedicated command for changing the domain name of a site which performs a search and replace across the database, but with more knowledge of the underlying data structure used by WordPress to avoid pitfalls mentioned above and to be as fast as possible.

Lots to consider here, I'll add notes to this issue that were raised during the chat.

Considerations

  • Handling the scheme. Need options for ignoring the scheme, and forcing it to https or http.
  • Input format. Does this just accept a host name or a URL including scheme?
  • Multisite behaviour. Will this be a network-wide change by default?
  • Which core tables and columns should be included by default? Assuming all others can be ignored because they'll never contain a domain name.
    • wp_commentmeta.meta_value
    • wp_comments.comment_author - maybe
    • wp_comments.comment_author_email
    • wp_comments.comment_author_url
    • wp_comments.comment_content
    • wp_links.link_url
    • wp_options.option_value
    • wp_postmeta.meta_value
    • wp_posts.post_content
    • wp_posts.post_title - maybe
    • wp_posts.post_excerpt
    • wp_posts.post_content_filtered
    • wp_posts.guid - see notes below
    • wp_terms.name - maybe
    • wp_termmeta.meta_value
    • wp_usermeta.meta_value
    • wp_users.user_email - see notes below
    • wp_users.user_url
    • wp_users.display_name - maybe
    • Any others?
  • Non-core database tables. Included by default? Likely yes.
  • GUIDs. There's a use case for both changing these and retaining them.
  • Email addresses. Same as above.
  • Subdomain (or possibly more generally, substring) matching behaviour. If you want to replace example.com with mydev.localhost, should subdomain.example.com be affected or not?
  • Considerations outside of the database, eg. any of the constants in wp-config.php.
  • Use the current site address or the domain in --url as the "from" domain, is there a need for it to be included as a separate flag in the command?
    • What about broken sites?
    • What about importing a database from elsewhere and WP_HOME and WP_SITEURL are defined in the config with a different domain.
@planetahuevo
Copy link

Great idea. This will simplify a lot of people lives. :)
I would like to add another consideration:

  • Make sure we do not replace email domain like @example.com (covered by substring, but wanted to make sure).

@kraftner
Copy link

This comes up again and again.

As it stands this issue feels quite epic to me (and probably others) and hence feels intimidating. Since it's been some time without any movement - can this maybe be broken up into smaller chunks so it is easier to tackle?

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

4 participants