#47185 closed defect (bug) (fixed)
Media files cannot be deleted under Windows since 5.2
Reported by: | tonybogdanov | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.2.1 | Priority: | normal |
Severity: | critical | Version: | 5.2 |
Component: | Filesystem API | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
The wp_delete_file_from_directory
function was introduced in 4.9.7 and is used when deleting media files from the uploads directory. However, it's internals were changed in 5.2 and the function no longer works on Windows.
The actual deletion is omitted if this check is truthy:
https://core.trac.wordpress.org/browser/tags/5.2/src/wp-includes/functions.php#L6292
And on a Windows machine trailingslashit
adds a forward slash /
at the end of the path whereas the first part of the path is using backslashes (due to realpath
), thus strpos
fails.
Additionally returning FALSE
from wp_delete_attachment_files
doesn't seem to be accounted for (haven't dug into it). When I delete a file in the media panel it "succeeds" even though the physical file hasn't been deleted.
Introduced in [45177].