From 5564545ea85cb8fa7ac682cd63808efe9d7aec42 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Tue, 15 Dec 2015 02:35:26 +0000 Subject: [PATCH] Filesystem: Revert [33648] and [34733] unfortunately these have caused issues for some servers, while fixing it for others. See #28013 Fixes #34976 for trunk Fixes #34976 for trunk git-svn-id: https://develop.svn.wordpress.org/trunk@35944 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-filesystem-ftpext.php | 12 +++++------- .../includes/class-wp-filesystem-ftpsockets.php | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/wp-admin/includes/class-wp-filesystem-ftpext.php b/src/wp-admin/includes/class-wp-filesystem-ftpext.php index bba4608a8c..e1202aedd2 100644 --- a/src/wp-admin/includes/class-wp-filesystem-ftpext.php +++ b/src/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -331,16 +331,14 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { * @param string $file * @return bool */ - public function exists( $file ) { - $path = dirname( $file ); - $filename = basename( $file ); + public function exists($file) { + $list = @ftp_nlist($this->link, $file); - $file_list = @ftp_nlist( $this->link, '-a ' . $path ); - if ( $file_list ) { - $file_list = array_map( 'basename', $file_list ); + if ( empty( $list ) && $this->is_dir( $file ) ) { + return true; // File is an empty directory. } - return $file_list && in_array( $filename, $file_list ); + return !empty($list); //empty list = no file, so invert. } /** diff --git a/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php b/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php index 75b43c33b8..fe74d33c1d 100644 --- a/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php +++ b/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php @@ -342,7 +342,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base { * @return bool */ public function exists( $file ) { - $list = $this->ftp->rawlist( $file, '-a' ); + $list = $this->ftp->nlist( $file ); if ( empty( $list ) && $this->is_dir( $file ) ) { return true; // File is an empty directory.