Make WordPress Core


Ignore:
Timestamp:
03/18/2015 07:21:33 PM (10 years ago)
Author:
ocean90
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-filesystem-ftpext.php

    r31215 r31815  
    276276    public function exists($file) {
    277277        $list = @ftp_nlist($this->link, $file);
     278
     279        if ( empty( $list ) && $this->is_dir( $file ) ) {
     280            return true; // File is an empty directory.
     281        }
     282
    278283        return !empty($list); //empty list = no file, so invert.
    279284    }
Note: See TracChangeset for help on using the changeset viewer.