Ticket #5586: 5586.3.diff

File 5586.3.diff, 6.1 kB (added by DD32, 6 months ago)
  • wp-admin/includes/class-wp-filesystem-direct.php

    old new  
    1313        function setDefaultPermissions($perm){ 
    1414                $this->permission = $perm; 
    1515        } 
    16         function find_base_dir($base = '.'){ 
     16        function find_base_dir($base = '.', $echo = false){ 
    1717                return str_replace('\\','/',ABSPATH); 
    1818        } 
    19         function get_base_dir($base = '.'){ 
    20                 return str_replace('\\','/',ABSPATH); 
     19        function get_base_dir($base = '.', $echo = false){ 
     20                return find_base_dir($base, $echo); 
    2121        } 
    2222        function get_contents($file){ 
    2323                return @file_get_contents($file); 
  • wp-admin/includes/class-wp-filesystem-ftpext.php

    old new  
    6262 
    6363        function connect(){ 
    6464                if ( $this->options['ssl'] && function_exists('ftp_ssl_connect') ) { 
    65                         $this->link = ftp_ssl_connect($this->options['hostname'], $this->options['port'],$this->timeout); 
     65                        $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'],$this->timeout); 
    6666                } else { 
    67                         $this->link = ftp_connect($this->options['hostname'], $this->options['port'],$this->timeout); 
     67                        $this->link = @ftp_connect($this->options['hostname'], $this->options['port'],$this->timeout); 
    6868                } 
    6969 
    7070                if ( ! $this->link ) { 
     
    7272                        return false; 
    7373                } 
    7474 
    75                 if ( ! ftp_login($this->link,$this->options['username'], $this->options['password']) ) { 
     75                if ( ! @ftp_login($this->link,$this->options['username'], $this->options['password']) ) { 
    7676                        $this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username'])); 
    7777                        return false; 
    7878                } 
     
    119119                //If we get this far, somethings gone wrong, change to / and restart the process. 
    120120                return $this->find_base_dir('/',$echo); 
    121121        } 
    122         function get_base_dir($base = '.'){ 
     122        function get_base_dir($base = '.', $echo=false){ 
    123123                if( empty($this->wp_base) ) 
    124                         $this->wp_base = $this->find_base_dir($base); 
     124                        $this->wp_base = $this->find_base_dir($base,$echo); 
    125125                return $this->wp_base; 
    126126        } 
    127127        function get_contents($file,$type='',$resumepos=0){ 
     
    298298        } 
    299299        function is_dir($path){ 
    300300                $cwd = $this->cwd(); 
    301                 if ( @ftp_chdir($this->link, $path) ) { 
     301                @ftp_chdir($this->link, $path); 
     302                if ( $this->cwd() != $cwd ) { 
    302303                        @ftp_chdir($this->link, $cwd); 
    303304                        return true; 
    304305                } 
     
    325326                return false; 
    326327        } 
    327328        function mkdir($path,$chmod=false,$chown=false,$chgrp=false){ 
    328                 if( !ftp_mkdir($this->link, $path) ) 
     329                if( !@ftp_mkdir($this->link, $path) ) 
    329330                        return false; 
    330331                if( $chmod ) 
    331332                        $this->chmod($path, $chmod); 
     
    337338        } 
    338339        function rmdir($path,$recursive=false){ 
    339340                if( ! $recursive ) 
    340                         return ftp_rmdir($this->link, $file); 
     341                        return @ftp_rmdir($this->link, $file); 
    341342 
    342343                //TODO: Recursive Directory delete, Have to delete files from the folder first. 
    343344                //$dir = $this->dirlist($path); 
  • wp-admin/includes/class-wp-filesystem-ftpsockets.php

    old new  
    122122                return $this->find_base_dir('/',$echo); 
    123123        } 
    124124 
    125         function get_base_dir($base = '.'){ 
     125        function get_base_dir($base = '.', $echo = false){ 
    126126                if( empty($this->wp_base) ) 
    127                         $this->wp_base = $this->find_base_dir($base); 
     127                        $this->wp_base = $this->find_base_dir($base, $echo); 
    128128                return $this->wp_base; 
    129129        } 
    130130 
  • wp-admin/includes/update.php

    old new  
    140140        if ( $wp_filesystem->errors->get_error_code() ) 
    141141                return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors); 
    142142 
     143        //Get the Base folder 
     144        $base = $wp_filesystem->get_base_dir(); 
     145 
    143146        // Get the URL to the zip file 
    144147        $r = $current->response[ $plugin ]; 
    145148 
     
    148151 
    149152        // Download the package 
    150153        $package = $r->package; 
    151         apply_filters('update_feedback', __("Downloading update from $package")); 
     154        apply_filters('update_feedback', sprintf(__("Downloading update from %s"), $package)); 
    152155        $file = download_url($package); 
    153156 
    154157        if ( !$file ) 
    155158                return new WP_Error('download_failed', __('Download failed.')); 
    156159 
    157160        $name = basename($plugin, '.php'); 
    158         $working_dir = ABSPATH . 'wp-content/upgrade/' . $name; 
     161        $working_dir = $base . 'wp-content/upgrade/' . $name; 
    159162 
    160163        // Clean up working directory 
    161164        if ( is_dir($working_dir) ) 
     
    175178 
    176179        // Remove the existing plugin. 
    177180        apply_filters('update_feedback', __("Removing the old version of the plugin")); 
    178         $plugin_dir = dirname(ABSPATH . PLUGINDIR . "/$plugin"); 
     181        $plugin_dir = dirname($base . PLUGINDIR . "/$plugin"); 
     182        $plugin_dir = trailingslashit($plugin_dir); 
    179183        // If plugin is in its own directory, recursively delete the directory. 
    180         if ( '.' != $plugin_dir && ABSPATH . PLUGINDIR != $plugin_dir ) 
     184        if ( '.' != $plugin_dir && $base . PLUGINDIR != $plugin_dir ) 
    181185                $deleted = $wp_filesystem->delete($plugin_dir, true); 
    182186        else 
    183                 $deleted = $wp_filesystem->delete(ABSPATH . PLUGINDIR . "/$plugin"); 
     187                $deleted = $wp_filesystem->delete($base . PLUGINDIR . "/$plugin"); 
    184188        if ( !$deleted ) { 
    185189                $wp_filesystem->delete($working_dir, true); 
    186190                return new WP_Error('delete_failed', __('Could not remove the old plugin')); 
     
    188192 
    189193        apply_filters('update_feedback', __("Installing the latest version")); 
    190194        // Copy new version of plugin into place. 
    191         if ( !copy_dir($working_dir, ABSPATH . PLUGINDIR) ) { 
     195        if ( !copy_dir($working_dir, $base . PLUGINDIR) ) { 
    192196                //$wp_filesystem->delete($working_dir, true); 
    193197                return new WP_Error('install_failed', __('Installation failed')); 
    194198        }