Skip to content Skip to sidebar

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 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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: 

This topic contains 26 replies, has 0 voices.

Last updated by Otto 6 months, 1 week ago.

Assisted by: Otto.

Author Posts
October 14, 2025 at 12:28 pm #17483759

Otto

Hello,

Our devs took a look. And despite we couldn't replicate the issue, in the next WPML release, there will be an extra guard when deleting translated attachments to restrict remove file from filesystem.

We think this should solve the issue.

When WPML 4.8.3 is available, please give it a try. ❌ Please make a full website backup before proceeding ❌

Best Regards,
Otto

October 14, 2025 at 12:51 pm #17483951

Natalie Wood

Thanks so much for the proposed solution.

I am already restricting the files being deleted (on my live system) by unchecking the "Delete translations when deleting a post" option.

But there is still the issue of the 'original' language of the image being changed from English to Danish for some images and the 'copied' status being incorrectly applied, when there is no actual copy
(as per my reply on October 6)

It is not workable like that.

Did you want me to open a new support ticket for that?

I feel that they are the same issue, with the incorrect 'copied' status being the precursor to the image being deleted.

October 14, 2025 at 1:36 pm #17484264

Otto

Hello,

Yes please, open a new ticket for this issue. This will keep things more clear. I am not sure if it's related, and I think that the solution that will be implemented does not address that scenario, but only prevents the file deletion.

Thanks!

Best Regards,
Otto

October 16, 2025 at 11:42 am #17490083

Otto

Hello,

WPML 4.8.3 was released and it should fix this issue.

❌ Please make a full website backup before proceeding ❌

Can you please give it a try?

Let us know how it goes, please.

Best Regards,
Otto

October 16, 2025 at 12:12 pm #17490161

Natalie Wood

Thanks

I will not have time try this at the moment

I do not need this solution as I unchecked the "Delete translations when deleting a post" option and that stops the deletes.

I now need a solution to the 'original' language being swapped on the images.

I know you don't think it is related but it obviously is.

I will make a new ticket

October 16, 2025 at 12:49 pm #17490357

Otto

Hello,

Sure, I understand.

Thank you for your patience and cooperation to investigate this problem.

Best Regards,
Otto

October 18, 2025 at 5:02 am #17495449

Natalie Wood

I have updated the plugins

WPML 4.8.3
WPML media translation 3.0.0
WPML string translation 3.4.1

On my Dev system I have just had an image file deleted so the update hasn't solved the problem:

Backtrace

[18-Oct-2025 04:32:44 UTC] delete_attachment called for Post ID: 8703
[18-Oct-2025 04:32:44 UTC] Image file hidden link
[18-Oct-2025 04:32:44 UTC] Backtrace:
[18-Oct-2025 04:32:44 UTC] File: wp-includes/class-wp-hook.php, Line: 326, Function: my_delete_attachment_caller_info
[18-Oct-2025 04:32:44 UTC] File: wp-includes/class-wp-hook.php, Line: 348, Function: WP_Hook->apply_filters
[18-Oct-2025 04:32:44 UTC] File: wp-includes/plugin.php, Line: 517, Function: WP_Hook->do_action
[18-Oct-2025 04:32:44 UTC] File: wp-includes/post.php, Line: 6655, Function: do_action
[18-Oct-2025 04:32:44 UTC] File: wp-includes/post.php, Line: 3725, Function: wp_delete_attachment
[18-Oct-2025 04:32:44 UTC] File: wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-post-synchronization.class.php, Line: 209, Function: wp_delete_post
[18-Oct-2025 04:32:44 UTC] File: wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-post-synchronization.class.php, Line: 128, Function: WPML_Post_Synchronization->delete_translations
[18-Oct-2025 04:32:44 UTC] File: wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-post-translation.class.php, Line: 157, Function: WPML_Post_Synchronization->delete_post_actions
[18-Oct-2025 04:32:44 UTC] File: wp-includes/class-wp-hook.php, Line: 326, Function: WPML_Post_Translation->delete_post_actions
[18-Oct-2025 04:32:44 UTC] File: wp-includes/class-wp-hook.php, Line: 348, Function: WP_Hook->apply_filters
[18-Oct-2025 04:32:44 UTC] File: wp-includes/plugin.php, Line: 517, Function: WP_Hook->do_action
[18-Oct-2025 04:32:44 UTC] File: wp-content/plugins/sitepress-multilingual-cms/classes/media-translation/PostWithMediaFiles.php, Line: 223, Function: do_action
[18-Oct-2025 04:32:44 UTC] File: wp-content/plugins/sitepress-multilingual-cms/classes/media-translation/PostWithMediaFiles.php, Line: 160, Function: WPML\MediaTranslation\PostWithMediaFiles->delete_duplicated_attachment
[18-Oct-2025 04:32:44 UTC] File: wp-content/plugins/sitepress-multilingual-cms/classes/media/duplication/class-wpml-media-attachments-duplication.php, Line: 673, Function: WPML\MediaTranslation\PostWithMediaFiles->delete_duplicated_copied_media
[18-Oct-2025 04:32:44 UTC] File: wp-content/plugins/sitepress-multilingual-cms/classes/media/duplication/class-wpml-media-attachments-duplication.php, Line: 559, Function: WPML_Media_Attachments_Duplication->maybe_clear_duplicated_copied_media_in_posts_queue
[18-Oct-2025 04:32:44 UTC] File: wp-includes/class-wp-hook.php, Line: 324, Function: WPML_Media_Attachments_Duplication->maybe_duplicate_original_post_media
[18-Oct-2025 04:32:44 UTC] File: wp-includes/class-wp-hook.php, Line: 348, Function: WP_Hook->apply_filters
[18-Oct-2025 04:32:44 UTC] File: wp-includes/plugin.php, Line: 517, Function: WP_Hook->do_action
[18-Oct-2025 04:32:44 UTC] File: wp-admin/includes/class-wp-screen.php, Line: 424, Function: do_action
[18-Oct-2025 04:32:44 UTC] File: wp-admin/includes/screen.php, Line: 243, Function: WP_Screen->set_current_screen
[18-Oct-2025 04:32:44 UTC] File: wp-admin/admin.php, Line: 213, Function: set_current_screen

The image that got deleted was not an image that had been recently uploaded. It was already used in a different page
I added it to a test page and translated the page

I've attached an image of the media translation screen for that image prior to it's deletion.
Note that although a db entry existed in both Danish and English for that image - it does not show as 'copied media' Is that correct???

I've attached an image of two of the other images in the page (that were not deleted) and I see that the do have 'copied media' next to them.

* where is the 'copied media' status saved in the database?

Also attached is the screen shot of the ate translation screen during translation

images-that-were-OK.png
test-page-ate.png
image-prior-to-deletion-in-media-translation-screen.png
October 18, 2025 at 12:32 pm #17495774

Natalie Wood

correction

The physical file wasn't actually deleted so the new code IS stopping the file delete

BUT

ALL DB entries for the image were deleted, so although the file was still there, in the media screen it wasn't showing the image as there is no DB entry in either language.

The image shows correctly on the front-end in the page as the physical file is still there.

These are the database records that were there for that image prior to the translation in the icl-translations table

(2658, 'post_attachment', 8702, 63090, 'en', NULL),
(2659, 'post_attachment', 8703, 63090, 'da', 'en'),

After the translation the above records were missing and the below records appeared.

(2956, 'post_attachment', NULL, 63260, 'da', NULL),
(2957, 'post_attachment', NULL, 63261, 'da', NULL),

My activity log recorded the delete of the entry for the post-id 8703 but not for the entry for post-id 8702 (I assume that one was removed using SQL code rather than a WordPress function)

It seems I can now reliably reproduce the above (i.e DB entries being deleted)

If the image DOES NOT have 'copied media' as the 'Media Type' on the media translation screen but does have a DB entry for both English and Danish then adding that image to an English page and translating it to Danish causes the DB entries to be deleted. (and hence is flagging the file for deletion. The file obviously not being deleted now because of the updated code)

It would be helpful to know where in the database the 'copied media' status is saved.

October 19, 2025 at 2:03 pm #17496971

Natalie Wood

This is where it goes wrong

in: PostWithMediaFiles.php

In this function delete_duplicated_copied_media()

here:
foreach ( $translations as $translation ) {
if ( $translation->language_code === $default_language_code || (int) $translation->element_id === (int) $copied_media_id ) {
continue;
}

For the image that got deleted neither of the above conditions matched even though it was a copied media.

The value of $copied_media_id has been set to the Danish version of the image instead if the English version of the image.

So it would seem that when the $copied_media_id values were set in the database they have been set incorrectly for some images

Was this done by the plugin when it updated?

How would I correct the images in the database?

October 20, 2025 at 1:30 pm #17499764

Otto

Hello,

Thanks for all the testing and the detailed explanation. I've sent your report to our second tier support. I'll get back to you as soon as I have a reply.

Best Regards,
Otto

October 22, 2025 at 6:27 am #17505269

Natalie Wood

Thanks Otto, I really appreciate your help and understanding

I just wanted to link my other ticket here for the devs as I think the change of original language in my other ticket is precursor to the delete issue

https://wpml.org/forums/topic/original-language-is-being-changed-on-some-images/

October 22, 2025 at 1:09 pm #17508156

Otto

Hello,

Thanks again. Your help is truly appreciated.

One of our devs is already taking care of this and preparing a fix to include in 4.8.4. I shared your insights from the other ticket so it's taken into account.

As mentioned, we are aiming for a fix in the next version, I'll keep you posted.

Best Regards,
Otto