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

Built from https://develop.svn.wordpress.org/trunk@34733


git-svn-id: http://core.svn.wordpress.org/trunk@34697 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2015-10-01 05:09:25 +00:00
parent 51ddf2ca9c
commit 731b51ee7f
2 changed files with 8 additions and 6 deletions

View File

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

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.4-alpha-34732'; $wp_version = '4.4-alpha-34733';
/** /**
* 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.