Ticket #7690: 7690.9.diff

File 7690.9.diff, 2.0 KB (added by DD32, 4 years ago)
  • wp-admin/includes/class-wp-filesystem-ssh2.php

     
    329329        function touch($file, $time = 0, $atime = 0) { 
    330330                //Not implmented. 
    331331        } 
    332  
     332         
    333333        function mkdir($path, $chmod = null, $chown = false, $chgrp = false) { 
     334                $path = trim($path, '/'); 
    334335                if( ! ssh2_sftp_mkdir($this->sftp_link, $path, $chmod, true) ) 
    335336                        return false; 
    336337                if( $chown ) 
     
    463464                } 
    464465                return $ret; 
    465466        } 
    466  
    467467        function __destruct(){ 
    468468                if ( $this->link ) 
    469469                        unset($this->link); 
  • wp-admin/includes/file.php

     
    405405                for ( $i = count($path) - 1; $i >= 0; $i-- ) { //>=0 as the first element contains data, count()-1, as we do not want the file component 
    406406                        $tmppath = $to . implode('/', array_slice($path, 0, $i) ); 
    407407                        if ( $fs->is_dir($tmppath) ) {//Found the highest folder that exists, Create from here 
    408                                 for ( $i = $i + 1; $i < count($path); $i++ ) { //< count() no file component please. 
     408                                for ( $i = $i + 1; $i <= count($path); $i++ ) { //< count() no file component please. 
    409409                                        $tmppath = $to . implode('/', array_slice($path, 0, $i) ); 
    410410                                        if ( ! $fs->mkdir($tmppath, 0755) ) 
    411411                                                return new WP_Error('mkdir_failed', __('Could not create directory'), $tmppath); 
     
    487487        } 
    488488 
    489489        if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') ) $method = 'ssh2'; 
     490 
    490491        if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext'; 
    491492        if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread 
    492493        return apply_filters('filesystem_method', $method);