~canonical-sysadmins/wordpress/4.4.2

« back to all changes in this revision

Viewing changes to wp-admin/includes/class-wp-filesystem-ftpext.php

  • Committer: Barry Price
  • Date: 2016-01-07 06:09:42 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: barry.price@canonical.com-20160107060942-1ghv2tqiwm8z0j36
Merge WP4.4.1 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
326
326
         * @param string $file
327
327
         * @return bool
328
328
         */
329
 
        public function exists( $file ) {
330
 
                $path = dirname( $file );
331
 
                $filename = basename( $file );
 
329
        public function exists($file) {
 
330
                $list = @ftp_nlist($this->link, $file);
332
331
 
333
 
                $file_list = @ftp_nlist( $this->link, '-a ' . $path );
334
 
                if ( $file_list ) {
335
 
                        $file_list = array_map( 'basename', $file_list );
 
332
                if ( empty( $list ) && $this->is_dir( $file ) ) {
 
333
                        return true; // File is an empty directory.
336
334
                }
337
335
 
338
 
                return $file_list && in_array( $filename, $file_list );
 
336
                return !empty($list); //empty list = no file, so invert.
339
337
        }
340
338
 
341
339
        /**