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)
Tagged: Bug
This topic contains 14 replies, has 0 voices.
Last updated by Otto 1 day, 6 hours 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, |
October 1, 2025 at 6:18 am #17447178 | |
Natalie Wood |
Thanks Otto OK that all makes sense. * So disabling “Delete translations when deleting a post” should actually resolve the problem. Obviously this doesn't fix the root cause but it should allow my live site to function correctly without fear of losing images during translation. * As regards the 'copied' status of an image, it seems to be a bit random. All these images are added in the same way: Added in the Media screen first and then added to a page that is then translated. I have added another image "copied-images.png" I can see the difference between them. The one that is copied obviously had a typo in the English alt text which I later went back and corrected, but that correction didn't change the alt text in the Danish image (which has the original English alt text with typo) - so now it is showing as copied. What is the status of the images that don't have 'copied' next to them? Those images do appear in both languages in the Media screen so they are 'copied' as far as I can see. *Could that be the issue that the image hasn't got a correct status? * Did the 'copied' attribute exist before the latest WPML update? i.e. did the update go through and assign the 'copied' status retrospectively? Note that I have never used the WPML media translation screen before. All translations of alt text etc have been done in the page. * In your code analysis it says: * Another thing is that I always remove the 'title' from all my images. But it seems that the Danish images retained the title (but that was never used in the front end as inserting the English image, inserts it without a title, so that is not part of the translation) Now however, since the image is not duplicated until it is added to a post, then the Danish image now has no title as well (I'm not sure if this is relevant but it is a change). Note that all the images that were deleted were added before the update to the WPML plugins though. *My suggestion is that the issue is that the image attachment record is being removed from the database for both languages and then obviously deleting the physical file is a logical next step in the code. Perhaps one of the devs could have a closer look at the code?? |
October 1, 2025 at 1:12 pm #17448952 | |
Otto WPML Supporter since 09/2015
Languages: English (English ) Spanish (Español ) Timezone: America/Argentina/Buenos_Aires (GMT-03:00) |
Hello, Thanks. Before escalating to our devs I need to understand the steps to recreate the issue. We are getting closer, I think. About the image classification: - **Copied image (duplicated)**: WPML creates a new `attachment` post per language (new DB ID) that points to the same physical file in `uploads`. You can localize title, caption, alt text, and slug per language. The file isn’t duplicated, only the record and its metadata. When is it classified? - **Not at upload time**: Uploading creates a single `attachment` in the current admin language (usually the default). No per-language copy is made yet. - **TL;DR**: Classification happens when the media is associated with translated content or duplication tools run—not when the file is uploaded. This is new, from 4.8. You mentioned that the images are "... added in the Media screen first and then added to a page that is then translated". And you also mention that they are added in the secondary language. By this you mean that when uploading the image you switched to the secondary language in the admin? Or you uploaded them in the original, duplicated the images, and then created a post in the secondary language and used them? What options did you have before updating in WPML > Settings > Media translation? Best Regards, |
October 6, 2025 at 6:43 am #17458223 | |
Natalie Wood |
1. Unfortunately I have no diagnostics running on my live site, but before I did the translation I looked at the images in the WPML translation editor and then after as well Attached are the before and after images. See that I uploaded the images in the English language and before I added them to the post they are showing correctly as only existing in English (as original language) and are not copied. After I did the translation they are showing as only Existing in Danish as original language and 'copied' but there isn't a copy! BUT see these images attached below They show another image that I had uploaded and added to the post in exactly the same way as the other two but after translation it has NOT had the 'original' language changed from English to Danish. Is it the correct behavior for the original language to be changed on some images? I definitely DO NOT want that behaviour as I work with all images in English and having some of them swapped to being in the Danish language as original makes it impossible to keep track of images. If that is the correct behaviour then how would I turn it off? 2. Note that on the live site I have unchecked the ''Delete translations when deleting a post' setting to prevent image deletions. 3. re 'copied' images. I guess my main question was whether it is correct that in the WPML media translation editor, some images show with nothing in the 'media type' column You say "- When you run the bulk tool in WPML → Media Translation → it creates the per‑language attachments at that moment → **copied**." * what is the 'bulk tool' ? 4. To clarify re adding images: That is all that is done. Then an image is used in a page (created in English) Then the page is translated to Danish 5. Steps to recreate the issue Edit a page Unfortunately with these steps the issue only occurs randomly 6. re your question: There is only one option there now which is to either have It was off when I first updated the wpml plugins and I set it to on *Were there any other Media translation options there prior to WPML plugin update? 7. I have an activity log in my dev site For the images that are being deleted by WPML the log only shows one entry for the image deletion - and it was for the Danish language entry in the Database. So it would seem the English language entry is being deleted first presumably via SQL as it is not in the log and then the Danish entry (and file) subsequently deleted. |
October 6, 2025 at 7:11 pm #17461835 | |
Otto WPML Supporter since 09/2015
Languages: English (English ) Spanish (Español ) Timezone: America/Argentina/Buenos_Aires (GMT-03:00) |
Hello, Thanks. I am still unable to reproduce the problem 🙁 I escalated the issue to our second tier support, I'll get back to you as soon as I have news from them. Best Regards, |