WordPress.org

Make WordPress Core

Changeset 11495


Ignore:
Timestamp:
05/30/09 17:14:07 (6 years ago)
Author:
westi
Message:

Fix plugin/theme upgrade issues when using ftp extension. Fixes #9980 props DD32.

Location:
trunk/wp-admin/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-filesystem-ftpext.php

    r11082 r11495  
    4848 
    4949        // Check if the options provided are OK. 
    50         if ( empty ($opt['username']) ) 
     50        if ( empty($opt['username']) ) 
    5151            $this->errors->add('empty_username', __('FTP username is required')); 
    5252        else 
    5353            $this->options['username'] = $opt['username']; 
    5454 
    55         if ( empty ($opt['password']) ) 
     55        if ( empty($opt['password']) ) 
    5656            $this->errors->add('empty_password', __('FTP password is required')); 
    5757        else 
     
    5959 
    6060        $this->options['ssl'] = false; 
    61         if ( isset($opt['ssl']) ) 
    62             $this->options['ssl'] = ( !empty($opt['ssl']) ); 
    63         elseif ( isset( $opt['connection_type']) ) 
    64             $this->options['ssl'] = ( 'ftps' == $opt['connection_type'] ); 
     61        if ( isset($opt['connection_type']) && 'ftps' == $opt['connection_type'] ) 
     62            $this->options['ssl'] = true; 
    6563    } 
    6664 
    6765    function connect() { 
    6866        if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') ) 
    69             $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'],$this->timeout); 
    70         else 
    71             $this->link = @ftp_connect($this->options['hostname'], $this->options['port'],$this->timeout); 
     67            $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], $this->timeout); 
     68        else 
     69            $this->link = @ftp_connect($this->options['hostname'], $this->options['port'], $this->timeout); 
    7270 
    7371        if ( ! $this->link ) { 
  • trunk/wp-admin/includes/file.php

    r11465 r11495  
    594594        return false; 
    595595 
    596     $abstraction_file = apply_filters('filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method); 
    597     if( ! file_exists($abstraction_file) ) 
    598         return; 
    599  
    600     require_once($abstraction_file); 
     596    if ( ! class_exists("WP_Filesystem_$method") ) { 
     597        $abstraction_file = apply_filters('filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method); 
     598        if( ! file_exists($abstraction_file) ) 
     599            return; 
     600     
     601        require_once($abstraction_file); 
     602    } 
    601603    $method = "WP_Filesystem_$method"; 
    602604 
     
    686688        unset($credentials['port']); 
    687689 
    688     if ( defined('FTP_SSH') || (isset($_POST['connection_type']) && 'ssh' == $_POST['connection_type']) ) 
     690    if ( defined('FTP_SSH') || (defined('FS_METHOD') && 'ssh' == FS_METHOD) ) 
    689691        $credentials['connection_type'] = 'ssh'; 
    690     else if ( defined('FTP_SSL') || (isset($_POST['connection_type']) && 'ftps' == $_POST['connection_type']) ) 
     692    else if ( defined('FTP_SSL') && 'ftpext' == $type ) //Only the FTP Extension understands SSL 
    691693        $credentials['connection_type'] = 'ftps'; 
    692     else if ( !isset($credentials['connection_type']) || (isset($_POST['connection_type']) && 'ftp' == $_POST['connection_type']) ) 
     694    else if ( !empty($_POST['connection_type']) ) 
     695        $credentials['connection_type'] = $_POST['connection_type']; 
     696    else if ( !isset($credentials['connection_type']) ) //All else fails (And its not defaulted to something else saved), Default to FTP 
    693697        $credentials['connection_type'] = 'ftp'; 
    694698 
     
    751755<tr valign="top"> 
    752756<th scope="row"><label for="password"><?php _e('Password') ?></label></th> 
    753 <td><input name="password" type="password" id="password" value=""<?php if( defined('FTP_PASS') ) echo ' disabled="disabled"' ?> size="40" /><?php if( defined('FTP_PASS') && !empty($password) ) echo '<em>'.__('(Password not shown)').'</em>'; ?></td> 
     757<td><input name="password" type="password" id="password" value="<?php if ( defined('FTP_PASS') ) echo '*****'; ?>"<?php if ( defined('FTP_PASS') ) echo ' disabled="disabled"' ?> size="40" /></td> 
    754758</tr> 
    755759 
     760<?php if ( extension_loaded('ssh2') ) : ?> 
    756761<tr id="ssh_keys" valign="top" style="<?php if ( 'ssh' != $connection_type ) echo 'display:none' ?>"> 
    757762<th scope="row"><?php _e('Authentication Keys') ?> 
     
    763768<div><?php _e('Enter the location on the server where the keys are located. If a passphrase is needed, enter that in the password field above.') ?></div></td> 
    764769</tr> 
     770<?php endif; ?> 
    765771 
    766772<tr valign="top"> 
     
    768774<td> 
    769775<fieldset><legend class="screen-reader-text"><span><?php _e('Connection Type') ?></span></legend> 
    770 <label><input id="ftp" name="connection_type"  type="radio" value="ftp" <?php checked('ftp', $connection_type); if ( defined('FTP_SSL') || defined('FTP_SSH') ) echo ' disabled="disabled"'; ?>/> <?php _e('FTP') ?></label><br /> 
    771 <label><input id="ftps" name="connection_type" type="radio" value="ftps" <?php checked('ftps', $connection_type); if ( defined('FTP_SSH') || defined('FTP_SSH') ) echo ' disabled="disabled"';  ?>/> <?php _e('FTPS (SSL)') ?></label><br /> 
    772 <?php if ( extension_loaded('ssh2') ) { ?><label><input id="ssh" name="connection_type" type="radio" value="ssh" <?php checked('ssh', $connection_type);  if ( defined('FTP_SSL') || defined('FTP_SSH') ) echo ' disabled="disabled"'; ?>/> <?php _e('SSH') ?></label><?php } ?> 
     776<label><input id="ftp" name="connection_type"  type="radio" value="ftp" <?php checked('ftp', $connection_type); if ( defined('FTP_SSL') || defined('FTP_SSH') ) echo ' disabled="disabled"'; ?>/> <?php _e('FTP') ?></label> 
     777<?php if ( 'ftpext' == $type ) : ?> 
     778<br /><label><input id="ftps" name="connection_type" type="radio" value="ftps" <?php checked('ftps', $connection_type); if ( defined('FTP_SSL') || defined('FTP_SSH') ) echo ' disabled="disabled"';  ?>/> <?php _e('FTPS (SSL)') ?></label> 
     779<?php endif; ?> 
     780<?php if ( extension_loaded('ssh2') ) : ?> 
     781<br /><label><input id="ssh" name="connection_type" type="radio" value="ssh" <?php checked('ssh', $connection_type);  if ( defined('FTP_SSL') || defined('FTP_SSH') ) echo ' disabled="disabled"'; ?>/> <?php _e('SSH') ?></label> 
     782<?php endif; ?> 
    773783</fieldset> 
    774784</td> 
Note: See TracChangeset for help on using the changeset viewer.