Make WordPress Core


Ignore:
Timestamp:
10/01/2015 05:08:07 AM (9 years ago)
Author:
dd32
Message:

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

File:
1 edited

Legend:

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

    r34493 r34733  
    317317     * @return bool
    318318     */
    319     public function exists($file) {
    320         $list = @ftp_rawlist( $this->link, '-a ' . $file );
    321 
    322         if ( empty( $list ) && $this->is_dir( $file ) ) {
    323             return true; // File is an empty directory.
    324         }
    325 
    326         return !empty($list); //empty list = no file, so invert.
     319    public function exists( $file ) {
     320        $path = dirname( $file );
     321        $filename = basename( $file );
     322
     323        $file_list = @ftp_nlist( $this->link, '-a ' . $path );
     324        if ( $file_list ) {
     325            $file_list = array_map( 'basename', $file_list );
     326        }
     327
     328        return $file_list && in_array( $filename, $file_list );
    327329    }
    328330
Note: See TracChangeset for help on using the changeset viewer.