Home›Support›English Support›[Escalated to WPML Developers team] WPML pugins & wp_delete_attachment do not delete files on disk
[Escalated to WPML Developers team] WPML pugins & wp_delete_attachment do not delete files on disk
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.
WordPress 6.7 has introduced a new issue that impact translations, please update WooCommerce and WPML to the latest versions before you report issues. More about this here - https://wpml.org/errata/php-error-wp-6-7-notice-function-_load_textdomain_just_in_time-was-called/
I'm using the following plugins:
- WPML Sitepress
- WPML all import
- WPALLIMPORT
I discover that the wordpress function "wp_delete_attachment" do not works correctly when WPML is active. It looks like WPML apply a filter on "wp_delete_file" and do not allow the wordpress function "wp_delete_attachment" to delete files on disk. The function removes correctly the media in the wordpress media library but DO NOT DELETE files on disk. I have thousands of orphan files and many gigabytes lost on the disk.
To be more precise, if I use this function to send media files to trash ""wp_delete_attachment( $file->ID, false );"" and I empty the trash after, files are correctly delete from the file system. BUT, if I ask to delete files immediately like "wp_delete_attachment( $file->ID, true );", files remains on the disk.
The same behavior occurs when I setup WPALLIMPORT to delete files.
I'm wondering how to fix this behavior.
It would be nice if WPML could fix that in a future release.
WPML shouldn't change the behavior of a native wordpress function when it is called thru a plugin or the file functions.php in the child theme .
I'll send the link of this ticket for information to WPALLIMPORT author.
I've made deep investigation and you should ask your DEV team to search the bug around filters applied on "wp_delete_file".
It is not only WPALLIMPORT who can not erase files on disk but also when I call the PHP function "wp_delete_attachment". I guess that the root issue is around those filters.
Languages: English (English )German (Deutsch )French (Français )
Timezone: Europe/Zagreb (GMT+01:00)
Hi,
The issue is within developers' queue, but when and how it will be handled, I'm afraid I cannot tell as I have no such information, it is up to developers to decide.