• Resolved Branimir Grbesic

    (@bgwebnorth)


    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:

    1. Upload an image. WPML creates three attachment posts, one per language, all sharing one _wp_attached_file value and one physical file.
    2. Switch admin language to any one of them, open that sibling.
    3. 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:504 calls @unlink($attached_file) directly. This bypasses the wp_delete_file filter, which WPML uses in WPML_Attachment_Action::delete_file_filter() to block deletion of files still referenced by sibling attachments. EMR’s own sub-size deletion in classes/compat.php does use wp_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.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.