I am trying to replace my previous backup / restore solution with WPworkbench, specially using CLI commands for automation. My previous solution does the automatic find/replace and saves me from manual work.
Yes, I could, but could you explain more about which database fields and in which tables still have the old domain name? And, we do update the wp_options table, and its siteurl, and home—it isn’t a problem for you, right?
Also, do we really need an option, or can we just always perform the replace?
I have a set of preconfigured plugins in the Wordpress that I use as boilerplate. Many of them save the domain name in one way or another. Another place I spotted them are in the custom fields attached to posts and pages, the domain names are not replaced. Another is my theme which saves some of my custom CSS codes in the database. The URL of background images stays as the old domain etc… that is why in general it is helpful to have a complete find and replace, no matter which table.
My previous solutions (Akeeba Backup) does this but asks for confirmation before applying the find/replace which I think is not needed or might make WPworkbench too complicated. I can’t recall clear reasons why when someone clones WP from domain1.com to domain2.com would need to keep some URLs in the database as domain1.com, but there might be cases I am not aware of. So maybe it can be an optional find/replace? or no?
Is there a case when such replacement wouldn’t be needed? I’m thinking of making it automatic since it’s highly unlikely that the old domain name needs to be preserved upon cloning?
Is the domain home directory also stored in the database?
Is there a case when such replacement wouldn’t be needed? I’m thinking of making it automatic since it’s highly unlikely that the old domain name needs to be preserved upon cloning?
I can’t think of any general case that replacement won’t be needed.
For the home directory, I only found one instance related to the backup plugin that was saved in the database.
I always backup the database and then do a search-and-replace on the href=“…” to transform all links into absolute local links (I wonder why WP doesn’t automatically just keep local links?)
Then only the two entries in the options table that define the site location need to be change.
Is there any down-side to using absolute local links, as long as they reference from the root (href=“/ ----”)?
If you remove the “https://www.mysite.ch” and keep the rest of the url starting with the first slash after the domain name then the links work irrespective of the domain name:
If you export the mysql or MariaDB and do a search-and-replace with a text editor, then you could replace all occurrences of “https://www.mysite.ch/” by “/”
That way all links become local, references the root of the public_html directory. Then re-import the sql file.
But the two entries in the WordPress options table for the keys “home” and “siteurl” that define the site root need to be left unchanged, which would normally be the case since they don’t end with a slash, so they don’t get replaced by the search-and-replace:
@kamyar.hu Alright, I’ve just added basic find and replace functionality. Now I’m wondering if we need more advanced options like --skip-tables, --skip-columns, --include-columns, or --regex-flags?
Example (with new not yet released WP Workbench Manager):
This looks amazing Ilia. I have rarely needed advanced search and replace options like -skip-tables , --skip-columns , --include-columns , or --regex-flags over years, and in those rare cases a WordPress plugin did the job. So it might be useful for some people at specific moments for sure, but I personally would not consider it as essential (needed).
If the automatic search and replace works during the cloning, replacing old domain with the new one in all the database that would do the job for me.