[wp-trac] [WordPress Trac] #54111: Delete attachment with sizes not working on Windows file system

WordPress Trac noreply at wordpress.org
Sat Dec 24 05:09:06 UTC 2022


#54111: Delete attachment with sizes not working on Windows file system
-------------------------------------------------+-------------------------
 Reporter:  kybernetikservices                   |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  Media                                |     Version:  5.8.1
 Severity:  normal                               |  Resolution:
 Keywords:  reporter-feedback has-patch dev-     |     Focuses:
  feedback                                       |
-------------------------------------------------+-------------------------
Changes (by bgoewert):

 * keywords:   => reporter-feedback has-patch dev-feedback
 * severity:  critical => normal


Comment:

 Hello @kybernetikservices and welcome to WordPress Trac!

 It's been 16 months since this was submitted. Are you still able to
 reproduce this issue? If so, can you provide a little more information
 about your environment, particularly the Windows Server and PHP version?

 ----

 Looking into `path_join()` brings me to
 [https://core.trac.wordpress.org/browser/tags/5.8.1/src/wp-
 includes/functions.php#L2049 path_is_absolute()] which implements some
 checks on the given path.

 If `E:/folder1/folder2/folder3/wp-content/uploads/extra-folder/91010
 /65535_49693031347_cd702ea089_h_1280_700_nofilter-300x164.jpg` was your
 actual path format, it seems like it would have failed all those checks.
 This is an invalid Windows path format (`/` vs `\`).

 One of the checks that `path_is_absolute()` performs uses `realpath()`
 which returns the correct path format, if this was a valid path. However,
 `path_is_absolute()` checks the canonical path against the ill-formatted
 one that was given, meaning this would not match.

 There is a Windows specific check as well. Although, this check does not
 take into account the ill-formatted path.

 I would venture to guess that somewhere in your plugin, or in your
 environment, the slashes got reversed and caused this to fail.

 What we ''could'' do is add `realpath()` to the Windows check to ensure
 it's using the correct path format.
 I've attached a patch for that and just need someone to review.

 [https://core.trac.wordpress.org/attachment/ticket/54111/54111.patch
 54111.patch]

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54111#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list