[wp-trac] [WordPress Trac] #47185: Media files cannot be deleted under Windows since 5.2

WordPress Trac noreply at wordpress.org
Wed May 8 15:07:15 UTC 2019


#47185: Media files cannot be deleted under Windows since 5.2
----------------------------+-----------------------------
 Reporter:  tonybogdanov    |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Filesystem API  |    Version:  5.2
 Severity:  critical        |   Keywords:
  Focuses:                  |
----------------------------+-----------------------------
 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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/47185>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list