Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
After duplicating all my products, some are still showing the "Needs Update" status and the debug log shows the following error:

[10-Apr-2023 18:10:55 UTC] WordPress database error Duplicate entry '20450-he' for key 'trid_lang' for query UPDATE `wp_icl_translations` SET `trid` = '20450', `language_code` = 'he', `source_language_code` = 'en' WHERE `element_type` = 'post_product' AND `element_id` = '36915' made by do_action('wp_ajax_wpml_action'), WP_Hook->do_action, WP_Hook->apply_filters, WPML\LIB\WP\Hooks::WPML\LIB\WP\{closure}, WPML\FP\Promise->resolve, WPML\FP\Promise->resolve, WPML\FP\Promise->resolve, WPML\FP\Promise->resolve, WPML\FP\Promise->resolve, WPML\FP\Promise->resolve, WPML\FP\Right->chain, WPML\FP\Right->map, WPML\Ajax\Factory->WPML\Ajax\{closure}, WPML\FP\Just->map, WPML\FP\{closure}, call_user_func_array, WPML\Container\Container::execute, WPML\Auryn\Injector->execute, call_user_func_array, WPML\Auryn\Executable->__invoke, ReflectionMethod->invokeArgs, WPML\TM\TranslationDashboard\Endpoints\Duplicate->run, WPML\FP\Fns::__callStatic, call_user_func_array, WPML\FP\Fns::WPML\FP\{closure}, call_user_func_array, WPML\FP\Fns::WPML\FP\{closure}, array_map, WPML\FP\{closure}, WPML\TM\TranslationDashboard\Endpoints\Duplicate->WPML\TM\TranslationDashboard\Endpoints\{closure}, SitePress->make_duplicate, WPML_Post_Duplication->make_duplicate, WPML_Post_Duplication->run_wpml_actions, SitePress->set_element_language_details, WPML_Set_Language->set, WPML_Set_Language->change_translation_of

Solution:
If you did a migration or DB search-replace, we suggest restoring the database if possible.

If not, you can run the following query after creating a full database backup:

DELETE FROM `wp_icl_translations` WHERE `element_id` IS NULL

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 33 replies, has 3 voices.

Last updated by rabiaA 1 year, 9 months ago.

Assisted by: Mohamed Sayed.

Author Posts
April 11, 2023 at 7:15 am #13442227

rabiaA

Just to confirm first,

You’re asking me to execute the below queries:

DELETE FROM `wp_postmeta`
WHERE `meta_key` = '_icl_lang_duplicate_of';
DELETE FROM `wp_icl_translations`
WHERE `language_code` = '';

What it will delete exactly?!

April 11, 2023 at 7:43 am #13442339

Mohamed Sayed

Hi,

The query will remove the duplicated postmeta key "_icl_lang_duplicate_of" and also remove the icl_translations entry where the langauge_code is blank.

Please note that you can also create a copy of your site using the Duplicator plugin (https://wordpress.org/plugins/duplicator/) and provide a link to download it.

The plugin will create a package file that you can upload to Google Drive or Dropbox and share the download link. Then we will import the copy and test the query locally.

Please check here for more details: https://wpml.org/faq/provide-supporters-copy-site/

Let me know please if you prefer to provide the site copy then I'll enable the private reply where you can securely share the link.

Thanks for your cooperation.

April 11, 2023 at 9:34 am #13443643

rabiaA

Simulate query Results before committing it:

SQL query:
DELETE FROM `wp_postmeta` WHERE `meta_key` = '_icl_lang_duplicate_of'
Matched rows: 508
Those 508 for the Arabic or for other language? How I can know that?

SQL query:
DELETE FROM `wp_icl_translations` WHERE `language_code` = ''
Matched rows: 0

April 11, 2023 at 9:40 am #13443671

Mohamed Sayed

Could you please provide us with the site copy to share with our developers for further investigation?

I've enabled the private reply.

April 11, 2023 at 9:42 am #13443677

rabiaA

Anyway, I've upgraded the Elementor to the latest version.

Executed both Delete queries but issue still remain, I still need to mention again that it's not for all the products in Hebrew.

I've 508 products, about 220 products can be duplicated but the rest are not.

April 11, 2023 at 9:49 am #13443753

rabiaA

Hi Muhammad,
I'm creating a copy, but it's failing on PHP Timeout from the Server.

Do we have other options to resolve this issue without providing the whole copy, the Website is a big one.

April 11, 2023 at 10:18 am #13444035

rabiaA

Hi Muhammad,

Can I share the link here? it's a private conversation?

April 11, 2023 at 10:58 am #13444509

Mohamed Sayed

Hi,

I've enabled the private reply again.

April 11, 2023 at 2:34 pm #13447251

Mohamed Sayed

Thanks, I imported the copy to our testing servers to make some tests but I couldn't find any clues.

I escalated this issue to our developers for further investigation and will update you once I get their reply.

Regards,
Mohamed

April 11, 2023 at 4:34 pm #13448625

rabiaA

Hi Muhammad,

You have reproduced the issue at least? You can see that there's issue there or not?

As you can see in the Screenshot,

Blue column is the Arabic and all duplicated successfully.
Green is the Hebrew which I can duplicated without any issue.
Yellow is the Hebrew which not able to be duplicated.

As you can see not all the Products have that issue, You can set this screen to display 100 items per page then go to Page "3" you will see the issue.

2023-04-11_19-31-52-YESNO.png
April 11, 2023 at 5:05 pm #13448863

Mohamed Sayed

Hi Rabiaah,

Yes, I can see the issue on the site's copy and I get the same database error once I try to duplicate any of those products with the "Needs update" status.

I'm still waiting for feedback from our developers and will update you once I get it.

April 12, 2023 at 9:59 am #13454195

rabiaA

Any updates guys, It's really blocking me to release the System to the customer.

April 12, 2023 at 11:21 am #13455027

Mohamed Sayed

Hi,

Sorry for the delay. Our 2nd tier support developers are currently working on this issue, but we don't have any updates yet.

I'll let you know once I get any feedback.

Thank you for your understanding.

April 12, 2023 at 1:27 pm #13456361

Mohamed Sayed

Hi,
Thanks for your patience!

The issue is happening because there are connected translations for Hebrew products but with NULL IDs (hidden link)

We are not sure how this happened. If you did a migration or DB search-replace, we suggest restoring the database if possible.

If not, you can run the following query after creating a full database backup:

DELETE FROM `wp_icl_translations` WHERE `element_id` IS NULL

We tested the query on the site's copy and those records were removed. Now we can duplicate the affected products as you can see here: hidden link

Please check and let us know your feedback.

Regards,
Mohamed

April 12, 2023 at 1:33 pm #13456413

rabiaA

I will test in 2 hours from now,

Just please confirm that all the 508 products duplicated successfully? As I have mentioned before that it’s happening in the last 300+/- products, first 220 products working fine, so please go to the last page and try the last 10 products…

Please confirmZ