WordPress.org

Make WordPress Core

Changeset 31815


Ignore:
Timestamp:
03/18/2015 07:21:33 PM (7 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.

Location:
trunk/src/wp-admin/includes
Files:
2 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    }
  • trunk/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php

    r31219 r31815  
    275275    public function exists( $file ) {
    276276        $list = $this->ftp->nlist( $file );
     277
     278        if ( empty( $list ) && $this->is_dir( $file ) ) {
     279            return true; // File is an empty directory.
     280        }
     281
    277282        return !empty( $list ); //empty list = no file, so invert.
    278283        // Return $this->ftp->is_exists($file); has issues with ABOR+426 responses on the ncFTPd server.
Note: See TracChangeset for help on using the changeset viewer.