Make WordPress Core

Ticket #11261: recursive-chmod.patch

File recursive-chmod.patch, 1.3 KB (added by reaperhulk, 15 years ago)

Patch using svn diff.

  • class-wp-filesystem-ftpext.php

     
    154154                                return false;
    155155                }
    156156
    157                 if ( ! $recursive || ! $this->is_dir($file) ) {
    158                         if ( ! function_exists('ftp_chmod') )
    159                                 return @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
    160                         return @ftp_chmod($this->link, $mode, $file);
     157                if ( $recursive && $this->is_dir($file) ) {
     158                        //fetch contents of the directory
     159                        $filelist = $this->dirlist($file);
     160                        //make sure the directory isn't empty by testing for the presence of a returned array
     161                        if( is_array($filelist) ) {
     162                                foreach ( $filelist as $filename=>$metadata ) {
     163                                        $this->chmod($file . '/' . $filename, $mode, $recursive);
     164                                }
     165                        }
    161166                }
    162                 //Is a directory, and we want recursive
    163                 $filelist = $this->dirlist($file);
    164                 foreach ( $filelist as $filename ) {
    165                         $this->chmod($file . '/' . $filename, $mode, $recursive);
    166                 }
    167                 return true;
     167                //chmod the file or directory
     168                if ( ! function_exists('ftp_chmod') )
     169                        return @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
     170                return @ftp_chmod($this->link, $mode, $file);
    168171        }
    169172        function chown($file, $owner, $recursive = false ) {
    170173                return false;