Data loss with WPML
-
Environment: 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
Steps:
- Upload an image. WPML creates three attachment posts, one per language, all sharing one
_wp_attached_filevalue and one physical file. - Switch admin language to any one of them, open that sibling.
- Replace media → “Replace the file, use the new file name, and update all links” → upload a differently named file.
Expected: all siblings follow the replacement, or the old file is retained while other posts still reference it.
Actual: 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.
Cause:
classes/Controller/ReplaceController.php:504calls@unlink($attached_file)directly. This bypasses thewp_delete_filefilter, which WPML uses inWPML_Attachment_Action::delete_file_filter()to block deletion of files still referenced by sibling attachments. EMR’s own sub-size deletion inclasses/compat.phpdoes usewp_delete_file_from_directory()and is correctly blocked, which is why the thumbnails survive and the loss goes unnoticed.Impact: irreversible loss of original media, silent because admin thumbnails continue to render.
Happy to provide additional information if needed.
- Upload an image. WPML creates three attachment posts, one per language, all sharing one
You must be logged in to reply to this topic.