[wp-trac] [WordPress Trac] #47868: wp_delete_attachment returning successfully, deleting all DB data, but NOT deleting files, and NOT returning false
WordPress Trac
noreply at wordpress.org
Wed Jul 2 16:38:07 UTC 2025
#47868: wp_delete_attachment returning successfully, deleting all DB data, but NOT
deleting files, and NOT returning false
------------------------------------+------------------------------
Reporter: Jossnaz | Owner: (none)
Type: defect (bug) | Status: closed
Priority: normal | Milestone: Awaiting Review
Component: Media | Version:
Severity: normal | Resolution: wontfix
Keywords: has-patch dev-feedback | Focuses:
------------------------------------+------------------------------
Changes (by callumbw95):
* status: new => closed
* resolution: => wontfix
Comment:
Hi All,
After reviewing the function's behavior and the discussion here, it's
clear that this is not a bug in WordPress Core.
The `wp_delete_attachment()` function is responsible for deleting the post
entry and its associated metadata from the database. The actual file
deletion is handled by `wp_delete_file()`, which is hooked into the
delete_attachment action. If the database entries are removed but the
files remain, it indicates that the function itself executed successfully,
but the hooked action to delete the files failed.
This failure is almost always due to incorrect file permissions on the
server, where the web server process lacks the rights to delete files from
the `wp-content/uploads` directory. WordPress Core cannot and should not
bypass server-level permissions. The responsibility for ensuring correct
file permissions lies with the server administrator.
Since the core function is behaving as designed, I am closing this ticket
as `wontfix`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47868#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list