{"id":18990522,"date":"2026-08-11T12:56:38","date_gmt":"2026-08-11T12:56:38","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/data-loss-with-wpml\/"},"modified":"2026-08-11T12:56:38","modified_gmt":"2026-08-11T12:56:38","slug":"data-loss-with-wpml","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/data-loss-with-wpml\/","title":{"rendered":"Data loss with WPML"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Environment:<\/strong> WordPress 7.0.3, WPML 4.9.6 + WPML Media Translation 3.1.2 (three active languages, media duplicated to translations), Enable Media Replace 4.2.2<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Steps:<\/strong><\/p>\n\n\n\n<ol>\n<li>Upload an image. WPML creates three attachment posts, one per language, all sharing one <code>_wp_attached_file<\/code> value and one physical file.<\/li>\n\n\n\n<li>Switch admin language to any one of them, open that sibling.<\/li>\n\n\n\n<li>Replace media \u2192 &#8220;Replace the file, use the new file name, and update all links&#8221; \u2192 upload a differently named file.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Expected:<\/strong> all siblings follow the replacement, or the old file is retained while other posts still reference it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Actual:<\/strong> only the invoked sibling is repointed. The old full-size file is deleted while two other attachment posts still reference it. Both remaining languages 404 on full size.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Cause:<\/strong> <code>classes\/Controller\/ReplaceController.php:504<\/code> calls <code>@unlink($attached_file)<\/code> directly. This bypasses the <code>wp_delete_file<\/code> filter, which WPML uses in <code>WPML_Attachment_Action::delete_file_filter()<\/code> to block deletion of files still referenced by sibling attachments. EMR&#8217;s own sub-size deletion in <code>classes\/compat.php<\/code> does use <code>wp_delete_file_from_directory()<\/code> and is correctly blocked, which is why the thumbnails survive and the loss goes unnoticed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Impact:<\/strong> irreversible loss of original media, silent because admin thumbnails continue to render.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Happy to provide additional information if needed.<\/p>\n","protected":false},"template":"","class_list":["post-18990522","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18990522","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18990522\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=18990522"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}