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 //Is a directory, and we want recursive
$file = trailingslashit($file); $file = trailingslashit($file);
$filelist = $this->dirlist($file); $filelist = $this->dirlist($file);
foreach ($filelist as $filename) foreach ( (array)$filelist as $filename => $filemeta)
$this->chmod($file . $filename, $mode, $recursive); $this->chmod($file . $filename, $mode, $recursive);
return true; return true;

View File

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

View File

@ -164,16 +164,15 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
return false; return false;
} }
if ( ! $recursive || ! $this->is_dir($file) ) { // chmod any sub-objects if recursive.
return $this->ftp->chmod($file, $mode); 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 // chmod the file or directory
$filelist = $this->dirlist($file); return $this->ftp->chmod($file, $mode);
foreach ( $filelist as $filename )
$this->chmod($file . '/' . $filename, $mode, $recursive);
return true;
} }
function chown($file, $owner, $recursive = false ) { function chown($file, $owner, $recursive = false ) {