Docs: Document directory support in FTP/SSH2 filesystem ::move() methods.

Props: costdev, flixos90, audrasjb.
Fixes: #57604.

git-svn-id: https://develop.svn.wordpress.org/trunk@55205 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2023-02-03 01:57:31 +00:00
parent 5872edc052
commit b85f581714
3 changed files with 34 additions and 13 deletions

View File

@ -358,13 +358,20 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
/**
* Moves a file.
* Moves a file or directory.
*
* After moving files or directories, OPcache will need to be invalidated.
*
* If moving a directory fails, `copy_dir()` can be used for a recursive copy.
*
* Use `move_dir()` for moving directories with OPcache invalidation and a
* fallback to `copy_dir()`.
*
* @since 2.5.0
*
* @param string $source Path to the source file.
* @param string $destination Path to the destination file.
* @param bool $overwrite Optional. Whether to overwrite the destination file if it exists.
* @param string $source Path to the source file or directory.
* @param string $destination Path to the destination file or directory.
* @param bool $overwrite Optional. Whether to overwrite the destination if it exists.
* Default false.
* @return bool True on success, false on failure.
*/

View File

@ -368,13 +368,20 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
/**
* Moves a file.
* Moves a file or directory.
*
* After moving files or directories, OPcache will need to be invalidated.
*
* If moving a directory fails, `copy_dir()` can be used for a recursive copy.
*
* Use `move_dir()` for moving directories with OPcache invalidation and a
* fallback to `copy_dir()`.
*
* @since 2.5.0
*
* @param string $source Path to the source file.
* @param string $destination Path to the destination file.
* @param bool $overwrite Optional. Whether to overwrite the destination file if it exists.
* @param string $source Path to the source file or directory.
* @param string $destination Path to the destination file or directory.
* @param bool $overwrite Optional. Whether to overwrite the destination if it exists.
* Default false.
* @return bool True on success, false on failure.
*/

View File

@ -496,20 +496,27 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
/**
* Moves a file.
* Moves a file or directory.
*
* After moving files or directories, OPcache will need to be invalidated.
*
* If moving a directory fails, `copy_dir()` can be used for a recursive copy.
*
* Use `move_dir()` for moving directories with OPcache invalidation and a
* fallback to `copy_dir()`.
*
* @since 2.7.0
*
* @param string $source Path to the source file.
* @param string $destination Path to the destination file.
* @param bool $overwrite Optional. Whether to overwrite the destination file if it exists.
* @param string $source Path to the source file or directory.
* @param string $destination Path to the destination file or directory.
* @param bool $overwrite Optional. Whether to overwrite the destination if it exists.
* Default false.
* @return bool True on success, false on failure.
*/
public function move( $source, $destination, $overwrite = false ) {
if ( $this->exists( $destination ) ) {
if ( $overwrite ) {
// We need to remove the destination file before we can rename the source.
// We need to remove the destination before we can rename the source.
$this->delete( $destination, false, 'f' );
} else {
// If we're not overwriting, the rename will fail, so return early.