Today i wanted to migrate my pagelines site to a new testdomain, where i can test the updating of the DMS2, Wordpress and all plugins.
Unfortunately my process of migrating Wordpress sites, like i'm doing it for many years now, did not work.
My process is:
- make an MySQL dump from the main site
- copying the wordpress folder from the main site
- create a new subomain for the test site
- create a new wordress test folder on the test server
- upload the copied FTP files to the new wordress test folder
- import the MySQL dump in a new test database on the server
- change all urls in the database to point to the new test domain (via a normal "Find and Replace" in a text editor)
This will lead to losing a ton of settings, templates and content due to this problem:
DMS stores serialized data in the database.
In this serialized data you can find hardcoded base urls and hardcoded filesystem urls.
An example is:
"description";s:56:"A responsive and sticky navigation bar for your website.";s:4:"name";s:6:"NavBar";s:8:"base_url";s:68:"http://test.domain.de/wp-content/themes/dms/sections/navbar";s:8:"base_dir";s:59:"/usr/www/users/test/wp-content/themes/dms/sections/navbar";s:9:"base_file";s:71:"/usr/www/users/test/wp-content/themes/dms/sections/navbar/section.php";s:9:"workswith"
Here you can find two issues:
- Never(!) store the base url like http://test.domain.de in the database.
=> The only fields which should contain the base url should be wordpress' own fields in the option table. The site url and the home url
- Never(!) store filesystem urls like /usr/www/users/test in the database
If you are storing urls in the db and you are reading from them, especially as DMS is doing it with serialized data, you get real pain when migrating a site via the normal MySQL dump/FTP dump migration process.
The problems are:
1. base urls like http://test.domain.de in serialized data
- Whenever the base url changes, maybe due to a customer renaming his brand, and the home and site url is changed in Wordpress, the whole DMS breaks if you don't update your database via an additional replacement script.
- When migrating: You really do have to replace all urls in your sql dump via a script, that knows how to replace serialized data.
For all you out there facing this issue - I found this tool, which works like a charm:
2. filesystem urls like /usr/www/users/test
- When migrating: You really do have to remember to change all stored filesystem urls to the new filesystem urls on the new server.
Firstly you have to find out the new filesystem url.
If you forget it, DMS breaks
I don't know, why DMS stores the base url additionally. The base url, or "home" is already perfectly present in the Wordpress options table and should be used centralised by any plugin or theme out there. E.g. by using home_url()
If one is storing the base url or even the filesystem urls additionally, like DMS is doing it, it's getting a pain when trying to migrate. And maybe not only when you are migrating...
This is not only an idea - It's a feature request which is essential in my opinion.