diff --git a/wp-admin/includes/class-wp-filesystem-ftpext.php b/wp-admin/includes/class-wp-filesystem-ftpext.php index 097cabdfd2..fc50aaf0ef 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 Rewrite using ftp_rawlist, uses 'LIST' on FTP server + * takes file path or directory path as parameter. * * @param string $file Path to file or directory. * @return bool Whether $file exists or not. */ public function exists( $file ) { - $list = ftp_nlist( $this->link, $file ); - - if ( empty( $list ) && $this->is_dir( $file ) ) { - return true; // File is an empty directory. + if ( $this->is_dir( $file ) ) { + return true; } - return ! empty( $list ); // Empty list = no file, so invert. + return ! empty( ftp_rawlist( $this->link, $file ) ); } /** @@ -510,9 +510,10 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { * Gets the file size (in bytes). * * @since 2.5.0 + * @since 6.1.0 Update for proper return values. * * @param string $file Path to file. - * @return int|false Size of the file in bytes on success, false on failure. + * @return int Size of the file in bytes on success, -1 on failure. */ public function size( $file ) { return ftp_size( $this->link, $file ); diff --git a/wp-admin/includes/class-wp-filesystem-ftpsockets.php b/wp-admin/includes/class-wp-filesystem-ftpsockets.php index 3c0c659456..d0fc128a1b 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpsockets.php +++ b/wp-admin/includes/class-wp-filesystem-ftpsockets.php @@ -414,19 +414,17 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base { * Checks if a file or directory exists. * * @since 2.5.0 + * @since 6.1.0 Rewrite using file size. * * @param string $file Path to file or directory. * @return bool Whether $file exists or not. */ public function exists( $file ) { - $list = $this->ftp->nlist( $file ); - - if ( empty( $list ) && $this->is_dir( $file ) ) { - return true; // File is an empty directory. + if ( $this->is_dir( $file ) ) { + return true; } - 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. + return is_numeric( $this->size( $file ) ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 86d70b4ba0..e1684c482b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-alpha-53859'; +$wp_version = '6.1-alpha-53860'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.