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. Built from https://develop.svn.wordpress.org/trunk@31815 git-svn-id: http://core.svn.wordpress.org/trunk@31797 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
80faa524fe
commit
9b79c36713
|
@ -275,6 +275,11 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||||
*/
|
*/
|
||||||
public function exists($file) {
|
public function exists($file) {
|
||||||
$list = @ftp_nlist($this->link, $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.
|
return !empty($list); //empty list = no file, so invert.
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -274,6 +274,11 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||||
*/
|
*/
|
||||||
public function exists( $file ) {
|
public function exists( $file ) {
|
||||||
$list = $this->ftp->nlist( $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 !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 $this->ftp->is_exists($file); has issues with ABOR+426 responses on the ncFTPd server.
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.2-beta1-31814';
|
$wp_version = '4.2-beta1-31815';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue