WP_Filesystem: Change WP_Filesystem_FTPext::exists() and WP_Filesystem_ftpsockets::exists() to return true for empty directories.

Both methods are using *nlist() which returns a list of files in a given directory or the file itself for a given file. If the result was an empty list we assumed that the file doesn't exists. This includes also cases where $file is actually an empty directory. To prevent this we now check if $file is a directory before returning the result of an empty list.
Other filesystem methods are using `file_exists()` which already checks whether a file or directory exists.

fixes #30815.

git-svn-id: https://develop.svn.wordpress.org/trunk@31815 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90)
2015-03-18 19:21:33 +00:00
parent 7476ac6d05
commit e9da1dc1f2
2 changed files with 10 additions and 0 deletions

View File

@@ -275,6 +275,11 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
*/
public function exists($file) {
$list = @ftp_nlist($this->link, $file);
if ( empty( $list ) && $this->is_dir( $file ) ) {
return true; // File is an empty directory.
}
return !empty($list); //empty list = no file, so invert.
}
/**

View File

@@ -274,6 +274,11 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
*/
public function exists( $file ) {
$list = $this->ftp->nlist( $file );
if ( empty( $list ) && $this->is_dir( $file ) ) {
return true; // File is an empty directory.
}
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.
}