Make WordPress Core

Changeset 12999


Ignore:
Timestamp:
02/07/2010 01:59:30 AM (14 years ago)
Author:
dd32
Message:

Standardise return values in WP_Filesystem::dirlist(), ::chmod() and ::exists()

Location:
trunk/wp-admin/includes
Files:
2 edited

Legend:

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

    r12998 r12999  
    161161        // chmod the file or directory
    162162        if ( ! function_exists('ftp_chmod') )
    163             return @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
    164         return @ftp_chmod($this->link, $mode, $file);
     163            return (bool)@ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
     164        return (bool)@ftp_chmod($this->link, $mode, $file);
    165165    }
    166166    function chown($file, $owner, $recursive = false ) {
     
    243243    }
    244244    function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
    245         if ( !ftp_mkdir($this->link, $path) )
     245        if ( !@ftp_mkdir($this->link, $path) )
    246246            return false;
    247247        $this->chmod($path);
     
    287287                return '';
    288288            $b = array();
    289             $b['isdir'] = $lucifer[0]{0} === "d";
    290             $b['islink'] = $lucifer[0]{0} === "l";
     289            $b['isdir'] = $lucifer[0]{0} === 'd';
     290            $b['islink'] = $lucifer[0]{0} === 'l';
    291291            if ( $b['isdir'] )
    292292                $b['type'] = 'd';
     
    335335        $list = @ftp_rawlist($this->link, '-a ' . $path, false);
    336336
    337         if ( $list === false )
     337        if ( empty($list) ) // Empty array = non-existant folder(real folder will show . at least
    338338            return false;
    339339
     
    355355            $dirlist[ $entry['name'] ] = $entry;
    356356        }
    357 
    358         if ( ! $dirlist )
    359             return false;
    360357
    361358        $ret = array();
  • trunk/wp-admin/includes/class-wp-filesystem-ftpsockets.php

    r12998 r12999  
    225225
    226226    function is_file($file) {
    227         return $this->is_dir($file) ? false : true;
     227        if ( $this->is_dir($file) )
     228            return false;
     229        if ( $this->exists($file) )
     230            return true;
     231        return false;
    228232    }
    229233
     
    289293
    290294        $list = $this->ftp->dirlist($path);
    291         if ( ! $list )
     295        if ( empty($list) && !$this->exists($path) )
    292296            return false;
    293297
Note: See TracChangeset for help on using the changeset viewer.