[wp-trac] [WordPress Trac] #36710: Symlinked directories should not be deleted recursively

WordPress Trac noreply at wordpress.org
Thu Apr 28 21:51:49 UTC 2016


#36710: Symlinked directories should not be deleted recursively
----------------------------+-----------------------------
 Reporter:  andy            |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Filesystem API  |    Version:  trunk
 Severity:  normal          |   Keywords:
  Focuses:  administration  |
----------------------------+-----------------------------
 When deleting a symlinked plugin, the current behavior is to recursively
 delete everything in the plugin's real directory and then fail to unlink
 the symlink because rmdir won't work on a symlink. This is probably not
 what the site admin intended when they installed the plugin via a symlink.
 The desired behavior is to unlink only the symlink, leaving the external
 directory intact so that other symlinks remain intact.

 My patch fixes this in WP_Filesystem rather than in the plugin deletion
 logic because it seems generally applicable to the use cases for symlinks.

 What makes this hard is that trailing slashes are significant when dealing
 with symlinked directories. The trailing slash causes the link to be
 followed:

 {{{
 is_link('/link/') => false
 is_link('/link') => true
 }}}

 The patch fixes deletion of symlinked plugins: it unlinks the symlink and
 leaves the real files intact. It should be carefully checked against other
 uses of delete because they might not include the trailing slash. In such
 cases, adding a trailing slash to the new `is_dir()` check might help.
 Could be a minefield, could be fine.

 Related to #29408 but not a duplicate.

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


More information about the wp-trac mailing list