Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 12:00 7:00 – 12:00 7:00 – 12:00 7:00 – 12:00 7:00 – 12:00 -
- 13:00 – 16:00 13:00 – 16:00 13:00 – 16:00 13:00 – 16:00 13:00 – 16:00 -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

Tagged: 

This topic contains 2 replies, has 0 voices.

Last updated by marilynC 3 weeks, 5 days ago.

Assisted by: Lucas Vidal de Andrade.

Author Posts
April 16, 2025 at 1:27 pm #16939126

marilynC

Background of the issue:
I recently moved my website from staging to live and since doing so, I have a lot of errors with WPML. I can't create new pages or I get fatal errors, new items can't be added to menus and other very critical similar issues. It seems like the root of the problem is with the database. I am trying to fix a bug where I get a couple of lines with an error like this: WordPress database error: [Duplicate entry '0' for key 'PRIMARY'] INSERT INTO `wp_icl_translations` (`element_type`, `language_code`, `trid`, `element_id`) VALUES ('post_nav_menu_item', 'en', '8097', '3363'). I did find some people talking about it online and telling solutions, but so far nothing worked for me. Here is what I tried: First I tried running this in mySQL: SELECT * FROM wp_icl_translations WHERE trid = 8097 AND language_code = 'en'. It returned me nothing and said this: MySQL returned an empty result set (i.e. zero rows). (Query took 0.0002 seconds.) After that I tried troubleshooting in the WordPress admin, I tried the solutions below and nothing worked: - Clear the cache in WPML - Remove ghost entries from the translation tables - Fix element_type collation - Set language information - Fix WPML tables collation - Assign translation status to duplicated content - Fix terms count - Fix post type assignment - Cleanup and optimize string tables. My website is running with these: WordPress version 6.8 Active theme: Salient Child Theme (version 1.0), parent Salient theme is up to date (version 17.1.0) Current plugin: WPML Multilingual CMS (version 4.7.3) PHP version 8.0.30

Symptoms:
Website Migration causes error (WordPress database error: [Duplicate entry '0' for key 'PRIMARY']) and now pages can't be created and menu can't be edited.

Questions:
How can I resolve the WordPress database error: [Duplicate entry '0' for key 'PRIMARY']?
What steps should I take to fix the issues with WPML after migrating my website?

April 16, 2025 at 2:04 pm #16939363

Lucas Vidal de Andrade
WPML Supporter since 11/2023

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey there,

I've enabled the private fields so you can share access to the staging version safely. Also, please tell me how I can reproduce the issue, so I can check it.

- If you do not see the wp-admin/FTP fields, this means your post and site login details are being made PUBLIC. DO NOT post your website details if you do not see the required wp-admin/FTP fields. If you do not, ask me to enable the private box. The private box looks like this:

hidden link

April 16, 2025 at 3:43 pm #16940078

marilynC

I have created a new staging. The DNS is now propagating. I will be giving you updates when it is up and running

April 16, 2025 at 3:48 pm #16940100

Lucas Vidal de Andrade
WPML Supporter since 11/2023

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Ok. The private fields are enabled. Please answer when you have the credentials and the website running.

April 17, 2025 at 2:57 pm #16944811

Lucas Vidal de Andrade
WPML Supporter since 11/2023

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey there,

I got an internal server error, when deactivating some plugins. Can you please restore the staging version? I'll create a local copy this time, so we don't run into this issue a second time. Thanks for your cooperation.

April 17, 2025 at 3:41 pm #16945012

marilynC

I fixed it!

April 17, 2025 at 7:04 pm #16945676

Lucas Vidal de Andrade
WPML Supporter since 11/2023

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey there,

Thank you so much. I was able to fix the issue in the testing environment you sent. Please test this before on a staging version before applying it and make sure to have a full website backup before proceeding:

Access PhpMyAdmin and run the following command:

ALTER TABLE wp_icl_translations CHANGE translation_id old_translation_id BIGINT(20) UNSIGNED NOT NULL;

then:

ALTER TABLE wp_icl_translations ADD COLUMN translation_id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;

and finally:

ALTER TABLE wp_icl_translations DROP COLUMN old_translation_id;

There was an issue with the auto-increment on the indexes of your translations, which sometimes happens on faulty migrations. The commands delete and recreates the translation_id column, with the auto-increment properly configured. Let me know if it works on your side.

April 21, 2025 at 7:07 pm #16952653

marilynC

I get an error on the second command, it just says I can't execute the command. If I only run the first and 3rd it deletes everything related to WPML, and I can't do any translation on my site

April 22, 2025 at 2:53 pm #16955965

Lucas Vidal de Andrade
WPML Supporter since 11/2023

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello,

Thanks for sharing your results. I couldn't create a copy of your staging version (I tried in different ways, but always got an error building the packages). In this case, please restore the staging version, so it matches your live website (at the moment, the issue is solved on the staging version). This way, I can recheck the steps and see what might be going wrong.

Let me know.

April 22, 2025 at 4:02 pm #16956449

marilynC

Ok it is fixed! I reset the staging so it is the same as the live version

April 23, 2025 at 5:30 pm #16961627

Lucas Vidal de Andrade
WPML Supporter since 11/2023

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello there.

Thanks for sharing. The steps didn't seem to work this time. In this case, please revert back to a previous backup, before running the SQL commands I shared. Then, update the staging version with that backup as well. Let me know.

I apologize for the back and forth, but I'll need to get a second opinion with my dev colleagues. When I shared the SQL queries, it worked flawlessly in the staging version when tested. Thanks for all the cooperation.

Regards,

April 23, 2025 at 7:50 pm #16961940

marilynC

Okay I reverted the staging DB to last week's version and did your corrections but still got the same issue with the second query. Here is an image of the error it gives me

Capture d’écran 2025-04-23 154633.png
April 23, 2025 at 8:30 pm #16961994

Lucas Vidal de Andrade
WPML Supporter since 11/2023

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Thank you for sharing. I think I expressed myself poorly, I apologize. Please restore the previous version and do not run the SQL queries. My idea is to take that to our devs as it was before. Thank you for your patience.

Let me know when the staging version matches that, so I can proceed.

April 24, 2025 at 11:55 am #16964098

marilynC

Okay I fixed it! Sorry about the confusion.

April 24, 2025 at 7:31 pm #16966032

Lucas Vidal de Andrade
WPML Supporter since 11/2023

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey there, I'm still checking your issue. I'll be back once I have new information. Thank you for your patience. No need to apologize 🙂

The topic ‘[Closed] Website Migration causes error (WordPress database error: [Duplicate entry '0' for key 'PRIMARY'…’ is closed to new replies.