Open k1sul1 opened 6 years ago
In order to pull the production database I first have to run wp-pull-production-db
, which breaks the installation.
I then have to run wp search-replace multisite.fi multisite.local --all-tables --url=http://multisite.fi
followed by a wp cache flush
.
I think that this is because the protocol is included in the replacement details, causing the replace to miss out on subdomains. Could the protocol be stripped entirely?
Define new and old siteurl for later search-replacing...
==> Production site URL: http://multisite.fi
==> Development site URL: http://multisite.local
==> This is a WordPress Network install.
Is the information above correct (yes/no)?
The protocol (or at least //
It's probably not a problem as long as you only go with pulls, pushing to the production database could be a problem.
Related issue: https://github.com/Seravo/wp-palvelu-vagrant/issues/37 "wp-pull-production-db fails for WP Network sites"
This is kind of a duplicate of #74
The latest Vagrant box released on Monday has an improved wp-pull-production-db command that now handles the main site of a network. Subdomains in a subdomain network cannot yet be automated however. See https://seravo.com/docs/get-started/release-notes/ and https://seravo.com/docs/configuration/wordpress-network/#local-development-with-vagrant-and-wordpress-network
I think we should probably wait for the Docker WP bootstrapping to be finalized so that we won't add more features to Vagrantfile anymore. After that, we can add support for multisite development via a config.yml feature that will trigger a use-network
command or something that adds the necessary wp-config.php
values and does the DB search replacing. I don't think it would make sense to document this now into https://seravo.com/docs, because according to the comments above using a multisite still requires some manual tinkering.
Was this already implemented in https://github.com/Seravo/docs/commit/c8a6b21b58766091070c0abcfe68bf4cb5598b2e or is there a need to extend the content of the commit?
Maybe some docs on how to add additional domains in config.yml and some mention that currently for the alternatives domains to work, they all need to be search-replaced from example.com to example.local, example.net to example-net.local etc. And that is currently not automated in any way, so all we offer is docs.
Getting this to work with an existing network wasn't too hard.
/etc/hosts
mappings get handled properly with this config:Adding these to the wp-config seems to be enough for WP to notice it's a network installation:
Then just create the machine with
vagrant up
, import the existing database if you have one and do search replaces; which is easy if there's only a single domain and no domain mapping:wp search-replace multisite.com multisite.local --all-tables # subdomains don't need to change!
In the case of domain mapping this becomes a bit harder, but one could use
wp site list --field=url
to get a list of all sites and write a script accordingly. Like replace the tld (.fi) of each site with a.local
.But that isn't a perfect solution, so I'm proposing adding a replacements prop to the Vagrant config. That requires a tiny bit of manual work, but it's more flexible and easier.
That would make it possible to handle cases with domain mapping nicely, and search-replace scripts could work automatically.