Fix recursive chmod for WP_Filesystem. Props reaperhulk for FtpExt. Fixes #11261

git-svn-id: http://svn.automattic.com/wordpress/trunk@12997 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32 2010-02-07 01:12:29 +00:00
parent 77c173c785
commit a8793e00c0
3 changed files with 18 additions and 19 deletions

View File

@ -135,7 +135,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
//Is a directory, and we want recursive
$file = trailingslashit($file);
$filelist = $this->dirlist($file);
foreach ($filelist as $filename)
foreach ( (array)$filelist as $filename => $filemeta)
$this->chmod($file . $filename, $mode, $recursive);
return true;

View File

@ -154,17 +154,17 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
return false;
}
if ( ! $recursive || ! $this->is_dir($file) ) {
if ( ! function_exists('ftp_chmod') )
return @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
return @ftp_chmod($this->link, $mode, $file);
// chmod any sub-objects if recursive.
if ( $recursive && $this->is_dir($file) ) {
$filelist = $this->dirlist($file);
foreach ( (array)$filelist as $filename => $filemeta )
$this->chmod($file . '/' . $filename, $mode, $recursive);
}
//Is a directory, and we want recursive
$filelist = $this->dirlist($file);
foreach ( $filelist as $filename ) {
$this->chmod($file . '/' . $filename, $mode, $recursive);
}
return true;
// 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);
}
function chown($file, $owner, $recursive = false ) {
return false;

View File

@ -164,16 +164,15 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
return false;
}
if ( ! $recursive || ! $this->is_dir($file) ) {
return $this->ftp->chmod($file, $mode);
// chmod any sub-objects if recursive.
if ( $recursive && $this->is_dir($file) ) {
$filelist = $this->dirlist($file);
foreach ( (array)$filelist as $filename => $filemeta )
$this->chmod($file . '/' . $filename, $mode, $recursive);
}
//Is a directory, and we want recursive
$filelist = $this->dirlist($file);
foreach ( $filelist as $filename )
$this->chmod($file . '/' . $filename, $mode, $recursive);
return true;
// chmod the file or directory
return $this->ftp->chmod($file, $mode);
}
function chown($file, $owner, $recursive = false ) {