diff --git a/wp-admin/includes/class-wp-filesystem-ftpext.php b/wp-admin/includes/class-wp-filesystem-ftpext.php index c3bb635809..296a5d2970 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpext.php +++ b/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -412,18 +412,18 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { * Checks if a file or directory exists. * * @since 2.5.0 - * @since 6.1.0 Uses WP_Filesystem_FTPext::is_dir() to check for directory existence - * and ftp_rawlist() to check for file existence. * * @param string $path Path to file or directory. * @return bool Whether $path exists or not. */ public function exists( $path ) { - if ( $this->is_dir( $path ) ) { - return true; + $list = ftp_nlist( $this->link, $path ); + + if ( empty( $list ) && $this->is_dir( $path ) ) { + return true; // File is an empty directory. } - return ! empty( ftp_rawlist( $this->link, $path ) ); + return ! empty( $list ); // Empty list = no file, so invert. } /** diff --git a/wp-admin/includes/class-wp-filesystem-ftpsockets.php b/wp-admin/includes/class-wp-filesystem-ftpsockets.php index f88166c209..192abc5ec4 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpsockets.php +++ b/wp-admin/includes/class-wp-filesystem-ftpsockets.php @@ -414,18 +414,19 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base { * Checks if a file or directory exists. * * @since 2.5.0 - * @since 6.1.0 Uses WP_Filesystem_ftpsockets::is_dir() to check for directory existence - * and file size to check for file existence. * * @param string $path Path to file or directory. * @return bool Whether $path exists or not. */ public function exists( $path ) { - if ( $this->is_dir( $path ) ) { - return true; + $list = $this->ftp->nlist( $path ); + + if ( empty( $list ) && $this->is_dir( $path ) ) { + return true; // File is an empty directory. } - return is_numeric( $this->size( $path ) ); + return ! empty( $list ); // Empty list = no file, so invert. + // Return $this->ftp->is_exists($file); has issues with ABOR+426 responses on the ncFTPd server. } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 3bb0ae220e..e913c9792d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.2-alpha-54813'; +$wp_version = '6.2-alpha-54815'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.