Skip Navigation

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:

If this solution doesn't look relevant to your issue, please open a new support ticket.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 12 replies, has 2 voices.

Last updated by Chainalysis 1 year ago.

Assisted by: Kor.

Author Posts
October 25, 2023 at 5:14 pm #14663605

Chainalysis

"This site has moved to a new location"

We weren't getting this problem in WPML 4.6.3.

I see this errata:
https://wpml.org/errata/this-site-has-moved-to-a-new-location-message-after-migrating-your-website/

And we are using 4.6.7 on a test copy of the site now, but the problem persists.

October 25, 2023 at 5:34 pm #14663777

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your patience.

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.

October 25, 2023 at 7:24 pm #14664467

Chainalysis

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.

October 25, 2023 at 7:31 pm #14664501

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your reply.

Would you be able to upload the site to a staging URL so that I could check this out for you?

October 27, 2023 at 8:30 pm #14682137

Chainalysis

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.

Also, Pantheon dynamically sets WP_HOME and WP_SITEURL, and WPML 4.6.4+ currently has a bug where this causes WPML to malfunction: see https://wpml.org/errata/persistent-warning-this-site-has-moved-to-a-new-location/

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.

I hope that that helps!

October 29, 2023 at 8:24 pm #14687367

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for sharing the fix.

Have a great day!

November 1, 2023 at 5:29 pm #14709441

Chainalysis

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?

November 1, 2023 at 6:04 pm #14709633

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your reply.

I've already shared your solution with our 2nd Tier Support and they will review it.

November 6, 2023 at 4:23 pm #14739943

Chainalysis

Hi Kor, it looks like the ticket status is "[Waiting for user feedback]". Do you need anything from me at this time?

November 6, 2023 at 4:39 pm #14740197

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your reply.

Sorry, I don't need anything further here. I'll reply to your other ticket shortly.

November 8, 2023 at 6:34 am #14752907

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your patience.

We already released a fix for this in WPML 4.6.7 by introducing a new button "Force-enable WPML’s Advanced Translation Editor" in the Troubleshooting page here is the updated link to the documentation page https://wpml.org/documentation/translating-your-contents/advanced-translation-editor/using-advanced-translation-editor-when-you-move-or-use-a-copy-of-your-site/#using-wpml-on-two-domains

November 8, 2023 at 9:46 pm #14761253

Chainalysis

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'"

November 8, 2023 at 9:47 pm #14761255

Chainalysis

Something went wrong when closing this ticket. It seems that the support forum feedback form might not work as expected in Firefox. Trying again.

November 8, 2023 at 9:51 pm #14761257

Chainalysis

Closing this ticket again from MacOS Safari, where the "issue is resolved" support form controls seem to work as expected.