This thread is resolved. Here is a description of the problem and solution.
Problem: The client was experiencing an issue with the message "This site has moved to a new location" after migrating their website and using WPML version 4.6.7 on a test copy of the site. The problem was occurring within Lando, used for local development, particularly with the Pantheon recipe.
Solution: If you're experiencing this issue with WPML and Lando for local development, here are the steps to resolve it: 1. Perform a search and replace from your production site URL to your local Lando URL using the following command:
lando wp search-replace '://www.mysite.com' '://my.lndo.site'
2. Flush or rebuild your cache with:
lando wp cache flush
3. Delete specific WPML settings from your database with the command:
lando wp db query "DELETE from pantheon.wp_options WHERE option_name = 'WPML_SITE_ID:ate' OR option_name = 'WPML_TM_AMS' OR option_name = 'otgs_wpml_tm_ate_cloned_site_lock'"
Additionally, we have released a fix in WPML 4.6.7 which includes a new button "Force-enable WPML’s Advanced Translation Editor" on the Troubleshooting page. For more details, you can refer to our documentation:
I will need to closely examine your website. Therefore, I will require temporary access (WP-Admin and FTP) to your Website.
Please note that it is important to have a backup for security purposes and to prevent any potential data loss. You can use the UpdraftPlus plugin (https://wordpress.org/plugins/updraftplus/) to fulfill your backup requirements.
Your upcoming reply will be treated with confidentiality and will only be visible to you and me.
✙ To resolve the issue, I may need your consent to deactivate and reactivate plugins and the theme, as well as make configuration changes on the site if necessary. This emphasizes the significance of having a backup.
Hi Kor, at this time, I only have a local copy of the site with WPML 4.6.7, using Lando (Docker).
The URL is hidden link, and this URL is registered on WPML as a development environment.
If it helps, I'm able to recreate this problem on a stock theme -- Twenty Twenty Three -- with all plugins deactivated except for the core WPML 4.6.7 plugin.
Hi, unfortunately, this problem exists within Lando, used for local development.
Fortunately, I found a workaround today, so I'll document it here in case other people run into this problem before there's a fix.
If you use Lando for local development and you use the Pantheon recipe because you have Pantheon hosting, it seems that Lando fails to successfully detect the 'pantheon' database, and so lando pull's search and replace of the site URLs fails. This problem isn't immediately obvious because the local site will work anyway with your local Lando URL despite this.
So to fix this, you need to take a few steps after you lando pull:
1. lando wp search-replace from your production site URL to your local Lando URL. The command will look something like this:
lando wp search-replace '://www.mysite.com' '://my.lndo.site'
2. lando wp cache flush (or rebuild, whatever you prefer)
3. And then delete the problematic WPML settings from your database:
lando wp db query "DELETE from pantheon.wp_options WHERE option_name = 'WPML_SITE_ID:ate' OR option_name = 'WPML_TM_AMS' OR option_name = 'otgs_wpml_tm_ate_cloned_site_lock'"
After this, you should be good to go, hopefully until there's an official fix for WPML's problem with dynamically-set WP_HOME and WP_SITEURL constants.
Hi Kor, I found a workaround but is there any chance of getting a permanent fix for WPML's issue with dynamically-set WP_HOME and WP_SITEURL constants?
Thank you, Kor. This helps a bunch to know. I just tested this "Force-enable" feature and it worked as expected.
We've also developed an automated workaround based on the info that you shared, for our case where we use Pantheon hosting plus Lando for local development.
I'll document it here in case it might help others.
There are two issues:
1. There's an issue/bug in Lando 3.20.x and maybe other Lando versions where the "pantheon" recipe doesn't 100% work as expected, because the automatic search-replace fails when you lando pull the database to your local env.
This affects the value of the WP_HOME and WP_SITEURL constants, which in turn impacts WPML.
So the workaround for this particular issue at the moment is to run a command like the following, and maybe add it to a local .sh script on your machine:
# `Update database with correct local domain`
lando wp search-replace '://www.mylivesite.com' '://my.lndo.site'
This alone isn't the entire problem -- there's still some sort of problem with WPML that we haven't figured out.
So here's the second step:
2. If/when your database contains all of the correct local URLs (see step #1), then you'll want to delete several wp_options records that WPML manages, such as WPML_SITE_ID:ate
The way to do this for Lando, either manually or in your local .sh script, is like so:
# `Workaround for WPML error "This site has moved to a new location" message after migrating your website`
lando wp db query "DELETE from pantheon.wp_options WHERE option_name = 'WPML_SITE_ID:ate' OR option_name = 'WPML_TM_AMS' OR option_name = 'otgs_wpml_tm_ate_cloned_site_lock'"
If you're creating a script to handle all of this -- steps #1 and #2 -- your end result might look something like the contents of the following example landopull.sh file.
I hope that this helps!
---
#!/usr/bin/env zsh
# `Pull db and files from prod, but not code`
lando pull --code=none --files=live --database=live
# `Update database with correct local domain`
lando wp search-replace '://www.mylivesite.com' '://my.lndo.site'
# `Rebuild local site to clear cache and redis, refresh the database, etc.`
lando wp cache flush
# `Workaround for WPML error "This site has moved to a new location" message after migrating your website`
lando wp db query "DELETE from pantheon.wp_options WHERE option_name = 'WPML_SITE_ID:ate' OR option_name = 'WPML_TM_AMS' OR option_name = 'otgs_wpml_tm_ate_cloned_site_lock'"