From d5f8d02445ad3bb092b417dc3b34e4da2d4da87e Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Fri, 3 Feb 2023 01:59:15 +0000 Subject: [PATCH] Docs: Document directory support in `FTP/SSH2` filesystem `::move()` methods. Props: costdev, flixos90, audrasjb. Fixes: #57604. Built from https://develop.svn.wordpress.org/trunk@55205 git-svn-id: http://core.svn.wordpress.org/trunk@54738 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../includes/class-wp-filesystem-ftpext.php | 15 +++++++++++---- .../includes/class-wp-filesystem-ftpsockets.php | 15 +++++++++++---- wp-admin/includes/class-wp-filesystem-ssh2.php | 17 ++++++++++++----- wp-includes/version.php | 2 +- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/wp-admin/includes/class-wp-filesystem-ftpext.php b/wp-admin/includes/class-wp-filesystem-ftpext.php index 296a5d2970..8b59d0525e 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpext.php +++ b/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -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. */ diff --git a/wp-admin/includes/class-wp-filesystem-ftpsockets.php b/wp-admin/includes/class-wp-filesystem-ftpsockets.php index 192abc5ec4..e64f47d44e 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpsockets.php +++ b/wp-admin/includes/class-wp-filesystem-ftpsockets.php @@ -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. */ diff --git a/wp-admin/includes/class-wp-filesystem-ssh2.php b/wp-admin/includes/class-wp-filesystem-ssh2.php index 540ecb54fa..351fbf6fb5 100644 --- a/wp-admin/includes/class-wp-filesystem-ssh2.php +++ b/wp-admin/includes/class-wp-filesystem-ssh2.php @@ -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. diff --git a/wp-includes/version.php b/wp-includes/version.php index c63aa31fae..19341fc374 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.2-alpha-55204'; +$wp_version = '6.2-alpha-55205'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.