This thread is resolved. Here is a description of the problem and solution.
Problem:
Yoast Duplicate Post duplicating "_wpml_media_featured" and "_wpml_media_duplicate"
Solution:
https://wpml.org/forums/topic/duplicate-entries-in-wp_postmeta/#post-13660521
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: Exception
This topic contains 13 replies, has 2 voices.
Last updated by jeannetteM 1 year, 11 months ago.
Assisted by: Bruno Kos.
Author | Posts |
---|---|
May 10, 2023 at 4:30 pm #13625487 | |
jeannetteM |
Good day I've just noticed that for each post, 43 entries with the key "_wpml_media_featured" and also 43 entries with the key "_wpml_media_duplicate" are created in the wp_postmeta table. All entries have the same values in the post_id and meta_value columns. It doesn't matter if the post has multiple revisions or not. We use the classic editor for the translations. Can you explain this behavior? Many thanks. |
May 10, 2023 at 5:03 pm #13625649 | |
jeannetteM |
I just noticed that when copying a post with the Yoast Duplicate Post extension, the existing "_wpml_media_featured" and "_wpml_media_duplicate" entries are copied and a new one of each is created. Accordingly, the entries multiply with each copy operation, since both entries are added each time, even if they already exist. I assume that the new ones are added by WPML each time. But wouldn't the extension have to check if the corresponding entries don't already exist before adding them? |
May 11, 2023 at 12:53 pm #13630485 | |
Bruno Kos WPML Supporter since 12/2018
Languages: English (English ) German (Deutsch ) French (Français ) Timezone: Europe/Zagreb (GMT+02:00) |
Hi, Thank you for contacting WPML support! These entries exist for each post because they control these 2 options so therefore they cannot be reused, but each post will have a new set of these keys. Regards, |
May 11, 2023 at 1:07 pm #13630723 | |
jeannetteM |
Hello Thank you very much for the explanations. The purpose of these entries is quite clear to me. Regards |
May 11, 2023 at 1:17 pm #13630817 | |
Bruno Kos WPML Supporter since 12/2018
Languages: English (English ) German (Deutsch ) French (Français ) Timezone: Europe/Zagreb (GMT+02:00) |
Hi, I see - indeed there should be only one _wpml_media_featured and _wpml_media_duplicate keys assigned to one post, even if the post has translations or duplicates. Can you tell me if this is the only affected post, or you can see this key being multiplied for several or even all the post IDs? Regards, |
May 11, 2023 at 1:24 pm #13630847 | |
jeannetteM |
Hi For almost all post IDs these keys exist multiple times, sometimes there are up to 43 duplicates per post ID. Kind regards |
May 11, 2023 at 2:00 pm #13631065 | |
Bruno Kos WPML Supporter since 12/2018
Languages: English (English ) German (Deutsch ) French (Français ) Timezone: Europe/Zagreb (GMT+02:00) |
Hi, Is there any action performed in backend you are aware of after which these entries get duplicated, perhaps original post edited or its translation, new post created, etc? Regards, |
May 11, 2023 at 2:23 pm #13631159 | |
jeannetteM |
Hi We create new posts by copying existing ones using Yoast Duplicate Post (new draft). Accordingly, I was able to trace the following process: With each copy operation the previous keys are copied and the keys "_wpml_media_featured" and "_wpml_media_duplicate" are added again. Accordingly, an additional set is added with each copy operation. Does this help a little? |
May 12, 2023 at 7:02 am #13634347 | |
Bruno Kos WPML Supporter since 12/2018
Languages: English (English ) German (Deutsch ) French (Français ) Timezone: Europe/Zagreb (GMT+02:00) |
Hi, This definitely helped as I was able to reproduce myself on this sandbox website: As far as I see is happening when I publish one of these duplicates, I did not notice that meta keys get duplicated if I only create a new draft without publishing. This has been escalated to our Compatibility team and may take some debugging time, I'll get back to you as soon as I have any news or questions for you. Regards, |
May 12, 2023 at 1:02 pm #13637661 | |
jeannetteM |
Hi Great that you were able to reproduce the problem. What I can't confirm though is that the keys are only duplicated when the post is published. For testing purposes, I copied the post with ID 57 on the sandbox website by just clicking on the link "New Draft" in the post overview at post 57. When the post 58 was opened in the editor, the database showed up as in the attached screenshot: At post 57 the two meta_keys were present 5 times each, but at post 58 they were already present 6 times each. I had neither resaved nor published the post. Thank you very much for escalating and your support. |
May 17, 2023 at 5:52 am #13660521 | |
Bruno Kos WPML Supporter since 12/2018
Languages: English (English ) German (Deutsch ) French (Français ) Timezone: Europe/Zagreb (GMT+02:00) |
Hi, Can you try this: Add these fields to Settings > Duplicate Post > Do not copy these fields, so both "_wpml_media_featured" and "_wpml_media_duplicate" or: add_filter('duplicate_post_excludelist_filter', 'wpml_compsupp6776_modify_duplicate_post_excludelist', 10, 1); function wpml_compsupp6776_modify_duplicate_post_excludelist($meta_blacklist) { $meta_blacklist[] = '_wpml_media_featured'; $meta_blacklist[] = '_wpml_media_duplicate'; return $meta_blacklist; } Does it work? Regards, |
May 17, 2023 at 9:44 am #13663053 | |
jeannetteM |
Hi That was much faster than expected. Thanks for the great tip. So far everything seems to work fine. I was also able to use the tip for a meta key of another plugin. I would now clean up the postmeta table with the following query: DELETE t1 FROM wp_postmeta AS t1 INNER JOIN wp_postmeta AS t2 WHERE t1.meta_id < t2.meta_id AND t1.post_id = t2.post_id AND t1.meta_key = t2.meta_key; Do you see any issues related to WPML that this could cause? Many thanks and kind regards |
May 17, 2023 at 1:00 pm #13664547 | |
Bruno Kos WPML Supporter since 12/2018
Languages: English (English ) German (Deutsch ) French (Français ) Timezone: Europe/Zagreb (GMT+02:00) |
Hi, I believe it should work and removal of these keys should not influence posts or their translations. Regards, |
May 17, 2023 at 4:55 pm #13666739 | |
jeannetteM |
My issue is resolved now. A thousand thanks for the support. |