Updates: Try a more compatible method to detect if a file exists when using the FTP Extension.

This change causes it to list the parent directories files, and assets that the node exists within the returned listing, this is a little more compatible than relying upon the FTP server to correctly filter the returned resultset to the specific file/node being requested.
Fixes #28013


git-svn-id: https://develop.svn.wordpress.org/trunk@34733 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse 2015-10-01 05:08:07 +00:00
parent d5fdd9084a
commit 0e2f9b5019
1 changed files with 7 additions and 5 deletions

View File

@ -316,14 +316,16 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
* @param string $file
* @return bool
*/
public function exists($file) {
$list = @ftp_rawlist( $this->link, '-a ' . $file );
public function exists( $file ) {
$path = dirname( $file );
$filename = basename( $file );
if ( empty( $list ) && $this->is_dir( $file ) ) {
return true; // File is an empty directory.
$file_list = @ftp_nlist( $this->link, '-a ' . $path );
if ( $file_list ) {
$file_list = array_map( 'basename', $file_list );
}
return !empty($list); //empty list = no file, so invert.
return $file_list && in_array( $filename, $file_list );
}
/**