From 65176075c05628081b11fe2b0bac59963512c589 Mon Sep 17 00:00:00 2001 From: dd32 Date: Sun, 7 Feb 2010 01:59:30 +0000 Subject: [PATCH] Standardise return values in WP_Filesystem::dirlist(), ::chmod() and ::exists() git-svn-id: http://svn.automattic.com/wordpress/trunk@12999 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-filesystem-ftpext.php | 15 ++++++--------- .../includes/class-wp-filesystem-ftpsockets.php | 8 ++++++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/wp-admin/includes/class-wp-filesystem-ftpext.php b/wp-admin/includes/class-wp-filesystem-ftpext.php index 9f6ca26284..795242b0ad 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpext.php +++ b/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -160,8 +160,8 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { // chmod the file or directory if ( ! function_exists('ftp_chmod') ) - return @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); - return @ftp_chmod($this->link, $mode, $file); + return (bool)@ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); + return (bool)@ftp_chmod($this->link, $mode, $file); } function chown($file, $owner, $recursive = false ) { return false; @@ -242,7 +242,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { return false; } function mkdir($path, $chmod = false, $chown = false, $chgrp = false) { - if ( !ftp_mkdir($this->link, $path) ) + if ( !@ftp_mkdir($this->link, $path) ) return false; $this->chmod($path); if ( $chown ) @@ -286,8 +286,8 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { if ( $lcount < 8 ) return ''; $b = array(); - $b['isdir'] = $lucifer[0]{0} === "d"; - $b['islink'] = $lucifer[0]{0} === "l"; + $b['isdir'] = $lucifer[0]{0} === 'd'; + $b['islink'] = $lucifer[0]{0} === 'l'; if ( $b['isdir'] ) $b['type'] = 'd'; elseif ( $b['islink'] ) @@ -334,7 +334,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { $list = @ftp_rawlist($this->link, '-a ' . $path, false); - if ( $list === false ) + if ( empty($list) ) // Empty array = non-existant folder(real folder will show . at least return false; $dirlist = array(); @@ -355,9 +355,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { $dirlist[ $entry['name'] ] = $entry; } - if ( ! $dirlist ) - return false; - $ret = array(); foreach ( (array)$dirlist as $struc ) { if ( 'd' == $struc['type'] ) { diff --git a/wp-admin/includes/class-wp-filesystem-ftpsockets.php b/wp-admin/includes/class-wp-filesystem-ftpsockets.php index a945d20d0a..c38bb295dd 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpsockets.php +++ b/wp-admin/includes/class-wp-filesystem-ftpsockets.php @@ -224,7 +224,11 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base { } function is_file($file) { - return $this->is_dir($file) ? false : true; + if ( $this->is_dir($file) ) + return false; + if ( $this->exists($file) ) + return true; + return false; } function is_dir($path) { @@ -288,7 +292,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base { } $list = $this->ftp->dirlist($path); - if ( ! $list ) + if ( empty($list) && !$this->exists($path) ) return false; $ret = array();