[wp-trac] [WordPress Trac] #57375: Add move_dir() function

WordPress Trac noreply at wordpress.org
Thu Dec 22 17:27:18 UTC 2022


#57375: Add move_dir() function
----------------------------+-----------------------
 Reporter:  afragen         |      Owner:  (none)
     Type:  enhancement     |     Status:  new
 Priority:  normal          |  Milestone:  6.2
Component:  Filesystem API  |    Version:  trunk
 Severity:  normal          |   Keywords:  has-patch
  Focuses:  performance     |
----------------------------+-----------------------
 WordPress lacks an internal function to move a directory from one location
 to another.

 WordPress has a `$wp_filesystem->move()` but `WP_Filesystem_Direct` it is
 designed with only a single file copy fallback. `copy_dir()` is a
 recursive file copy from one  location to another. `copy_dir()` is
 effective but it is more resource intensive and does require the user to
 delete the source after copying.

 `move_dir()` is a battle tested function that has been part of testing for
 a feature plugin having over 8000+ active installs.

 The idea is to use `rename()` with `copy_dir()` as a fallback. Non-direct
 WP_Filesytem `move()` commands are a variation of `rename()` all of which
 report a boolean result with no fallback. This means that a failure will
 be caught and the fallback will be used.

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


More information about the wp-trac mailing list