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 |
---|---|---|---|---|---|---|
- | 9:00 – 13:00 | 5:00 – 13:00 | 5:00 – 13:00 | 5:00 – 13:00 | 5:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: America/Argentina/Buenos_Aires (GMT-03:00)
This topic contains 10 replies, has 0 voices.
Last updated by Otto 11 hours, 7 minutes ago.
Assisted by: Otto.
Author | Posts |
---|---|
September 22, 2025 at 11:12 am #17421346 | |
Natalie Wood |
Background of the issue: Symptoms: Questions: |
September 22, 2025 at 6:08 pm #17423150 | |
Otto WPML Supporter since 09/2015
Languages: English (English ) Spanish (Español ) Timezone: America/Argentina/Buenos_Aires (GMT-03:00) |
Hello, Your debug backtrace shows the delete call originates in WPML Media Translation’s duplication/cleanup flow, specifically through WPMLMediaTranslation\PostWithMediaFiles and WPML_Media_Attachments_Duplication when WPML thinks an attachment is a duplicated copy to be cleared. Please try the following: If this does not help, although the backtrace points to WPML it's worth to try the following test. Many times what triggers the problem is a compatibility issue: Best Regards, |
September 23, 2025 at 1:27 pm #17425673 | |
Natalie Wood |
Thanks The error was not resolved by that As I said the error doesn't happen after every translation. It took 22 times trying the translation before the error happened again, so disabling plugins and testing and then enabling one by one is going to take a huge amount of time. Unfortunately I can't see a pattern as to what triggers the error. Note that prior to the update of the WPML plugins there had never been a problem, so it is some issue with the updates. To narrow it down: at the time I did the WPML updates, I also updated Gravity Forms multilingual and Advanced custom fields. That was all. Was there an update to the advanced translation editor as well? Can you give me more information on the situation, whereby WPML decides it has to delete an image? Note that the last two times only one image has been deleted but other times it was more than one image. But never all the images in the post. I am testing on my dev site, but the live site has the same issue as I updated the WPML plugins there before I realised this was an issue. Is there any way I can roll-back to the previous versions of the WPML plugins, just so that I can have the live site functional? Also will it make any difference if I uncheck the: "When deleting a post, delete translations as well" setting? Would that stop image delete? Thanks for any help you can give as this is a very difficult issue to troubleshoot. |
September 23, 2025 at 2:59 pm #17426145 | |
Otto WPML Supporter since 09/2015
Languages: English (English ) Spanish (Español ) Timezone: America/Argentina/Buenos_Aires (GMT-03:00) |
Hello, Yes, I understand how hard and frustrating these kinds of issues are 🙁 You said that it took 22 attempts before you could reproduce the problem. You mean that you saved 22 times the same translation, or you saved 22 different translations until you were able to see the problem? What kind of images are deleted from the post? I mean, are those regular image attachments or added in a custom field or as a gallery? In the last version, WPML changed how media is handled: So, which type of media is being deleted can give us a clue. Did you enable automatic detection in WPML > Settings > Media Translation? About your questions: - When does WPML decide to delete an image? 133:161:/Users/ofwald/Local Sites/for-cursor/app/public/wp-content/plugins/sitepress-multilingual-cms/classes/media-translation/PostWithMediaFiles.php public function delete_duplicated_copied_media() { ... if ( $texts['caption'] !== $translation_texts['caption'] || $texts['description'] !== $translation_texts['description'] || $texts['alt'] !== $translation_texts['alt'] ) { continue; } $this->delete_duplicated_attachment( $translation->element_id ); } 190:231:/Users/ofwald/Local Sites/for-cursor/app/public/wp-content/plugins/sitepress-multilingual-cms/classes/media-translation/PostWithMediaFiles.php private function delete_duplicated_attachment( $post_id ) { global $wpdb; ... // Deletes terms/meta, fires delete_post/deleted_post, then: $result = $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) ); ... return $post; } The above focuses on the attachment post/DB. In some environments, other processes can remove files once attachments disappear or if they share paths, but the core cleanup uses SQL (not wp_delete_attachment). - Will unchecking “When deleting a post, delete translations as well” stop image deletes? - Was there an Advanced Translation Editor (ATE) update too? Best Regards, |
September 24, 2025 at 5:21 am #17427343 | |
Natalie Wood |
Thanks I don't quite understand from your explanation how the image is being deleted. You seem to suggest that only the DB post is being deleted however it is clear from the backtrace that WPML is deleting the file - so where in the logic does this happen? One thing that may be relevant is that I create posts in English then translate to Danish however Danish is the default language. Yes I have checked the "Automatically detect best options for translating image texts" option, however I did turn it off at one point and the images were still being deleted. The images are added to the post in an image block. My theme is GeneratePress and I use a GenerateBlocks image block for all images. The Post I'm working on has about 23 images. It was 22 translations of the same post that I did. Each time I did a minor (or no) edit in the English then did the translation to match. I tried various types of edits and translations to see if I could see any pattern. I have a feeling that there is an issue with ATE. I have noticed some inconsistencies when I open the translation. Sometimes suddenly there is a field that is not translated. During the above testing at one point the slug was suddenly untranslated, although that was not the time the media were deleted. I've attached what shows in ATE for the image that has been deleted the last two times it happened. You can see that the ALT text is different for the translation so it shouldn't think that it is a 'duplicate' at all, Except of course now I realise that that 'ALT' is in the post and the translation is in the post. We never actually do a translation in the media file itself - is that the issue? I have activity logging on Finally please let me know how I can roll back to the previous versions of the WPML plugins |
September 24, 2025 at 5:00 pm #17429949 | |
Otto WPML Supporter since 09/2015
Languages: English (English ) Spanish (Español ) Timezone: America/Argentina/Buenos_Aires (GMT-03:00) |
Hello, Thanks for the detailed explanation. About rolling back. It’s generally safe—but do it carefully and in lockstep. - What “safe” rollback means - Compatibility notes - Recommended rollback steps - Will this help with the image deletions? Back to this weird and random issue: - What actually deletes the file - Why cleanup might incorrectly classify “duplicates” - Why turning off “Automatically detect best options for translating image texts” didn’t stop it - On ATE updates Best Regards, |
September 26, 2025 at 1:30 pm #17436149 | |
Natalie Wood |
Thanks *can you advise how to get the previous versions of the WPML plugins - I don't see that option in the "commercial tab" You have said that "unchecking 'When deleting a post, delete translations as well' won't stop image deletes" However from the backtrace the call to delete the attachment is coming via: The code around line 128 is: if ( $this->sync_delete || Lst::includes( $post_type, [ 'wp_template', 'wp_template_part' ] ) ) { To me it seems the value of $this->sync_delete is set by: There is a lot more I think I need to understand about images before I'm going to get to the bottom of this. So I've just uploaded a new image in English language. I see that is ISN'T duplicated into Danish language Then I added the image to a page and translated the page. Then I see that the image IS duplicated into the Danish language i.e. there is a post for it. I did translate the ALT text in the page but the duplicated image doesn't get the translated ALT text. You say that: "Your default language is Danish but you create in English. That can increase mapping edge cases (TRIDs/“duplicate-of” links)," *Does this mean the WPML doesn't support creating content in the non-default language? Further to all this there seem to be some inconsistent post-attachment records in the ICL-translations table. These are recent and I suspect they are caused by the images being deleted. They may be part of the problem but I notice in the live database that there aren't any inconsistent records but it also suffered from deleted images. I've attached an image of some of the inconsistent records. Even if I roll back the WPML plugins on my live site, I will have to keep trying to resolve this on dev . I will keep testing but as it is difficult to replicate the error it may take some time. *Can we keep this issue open? |
September 26, 2025 at 3:11 pm #17436627 | |
Otto WPML Supporter since 09/2015
Languages: English (English ) Spanish (Español ) Timezone: America/Argentina/Buenos_Aires (GMT-03:00) |
Hello, You can get previous versions going to wpml.org/downloads, expand "Download manually" and the click on the changelog icon for each plugin. Check the screenshot attached, please. Yes, the behavior is correct, with the latest version attachments are not duplicated until it's needed. About, creating content in non-default language. It's supported, I meant that in a complex setup it may increase the chance of failure. But we need to understand how it's failing. Yes, the ticket will remain open for 2 weeks without activity. About the code you are pointing as the root cause of the problem. I am not sure... As far as I know, when dealing with attachments, WPML does not handle physical files, it handles them at the DB level. But I'd like to take a better look at the issue. Is it possible for you to provide me with a copy of the site? You can use Duplicator or just a DB dump and the wp-content folder. I am enabling a private reply in case it's OK, so you can share a download link safely. If not, I'd try to reproduce it on a test environment. Best Regards, |
September 29, 2025 at 1:23 pm #17441144 | |
Otto WPML Supporter since 09/2015
Languages: English (English ) Spanish (Español ) Timezone: America/Argentina/Buenos_Aires (GMT-03:00) |
Hello, Thanks. I managed to deploy the copy of your site locally. I noted a warning message (check the screenshot attached): But WPML is active. Do you also see it? Just checking if it's a problem of the migration or if it may be an issue. Best Regards, |
September 29, 2025 at 1:48 pm #17441338 | |
Natalie Wood |
No i don't have that message on my site. Is it just because of the sitekey that you need to update. My sitekey won't work on your install |
September 29, 2025 at 6:13 pm #17442100 | |
Otto WPML Supporter since 09/2015
Languages: English (English ) Spanish (Español ) Timezone: America/Argentina/Buenos_Aires (GMT-03:00) |
Hello, I spent some time trying to reproduce the problem with no luck 🙁 I tried in the copy of your site, in the pages that you mentioned, and also tried in a fresh installation. I couldn't reproduce the problem. I analyzed the code with the help of AI. According to it, these are the conditions to make it happen and how to mitigate it: When can images get deleted? Required conditions for deletion Not deleted if: I tried these conditions without luck, and you also tried disabling automatic media handling, so I have doubts about its accuracy. Does this point you to any pattern that may help us find clear steps to reproduce the problem? Best Regards, |