From 7a9955a64aa240d7e43d006ce469aafcd76bbd58 Mon Sep 17 00:00:00 2001 From: westi Date: Sat, 30 May 2009 17:14:07 +0000 Subject: [PATCH] Fix plugin/theme upgrade issues when using ftp extension. Fixes #9980 props DD32. git-svn-id: http://svn.automattic.com/wordpress/trunk@11495 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../includes/class-wp-filesystem-ftpext.php | 14 ++++---- wp-admin/includes/file.php | 34 ++++++++++++------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/wp-admin/includes/class-wp-filesystem-ftpext.php b/wp-admin/includes/class-wp-filesystem-ftpext.php index 8b1e6088d..24611c923 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpext.php +++ b/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -47,28 +47,26 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { $this->wp_base = $opt['base']; // Check if the options provided are OK. - if ( empty ($opt['username']) ) + if ( empty($opt['username']) ) $this->errors->add('empty_username', __('FTP username is required')); else $this->options['username'] = $opt['username']; - if ( empty ($opt['password']) ) + if ( empty($opt['password']) ) $this->errors->add('empty_password', __('FTP password is required')); else $this->options['password'] = $opt['password']; $this->options['ssl'] = false; - if ( isset($opt['ssl']) ) - $this->options['ssl'] = ( !empty($opt['ssl']) ); - elseif ( isset( $opt['connection_type']) ) - $this->options['ssl'] = ( 'ftps' == $opt['connection_type'] ); + if ( isset($opt['connection_type']) && 'ftps' == $opt['connection_type'] ) + $this->options['ssl'] = true; } function connect() { if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') ) - $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'],$this->timeout); + $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], $this->timeout); else - $this->link = @ftp_connect($this->options['hostname'], $this->options['port'],$this->timeout); + $this->link = @ftp_connect($this->options['hostname'], $this->options['port'], $this->timeout); if ( ! $this->link ) { $this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port'])); diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index 61f3e8a0d..9cc8c22d0 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -593,11 +593,13 @@ function WP_Filesystem( $args = false ) { if ( ! $method ) return false; - $abstraction_file = apply_filters('filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method); - if( ! file_exists($abstraction_file) ) - return; - - require_once($abstraction_file); + if ( ! class_exists("WP_Filesystem_$method") ) { + $abstraction_file = apply_filters('filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method); + if( ! file_exists($abstraction_file) ) + return; + + require_once($abstraction_file); + } $method = "WP_Filesystem_$method"; $wp_filesystem = new $method($args); @@ -685,11 +687,13 @@ function request_filesystem_credentials($form_post, $type = '', $error = false) else unset($credentials['port']); - if ( defined('FTP_SSH') || (isset($_POST['connection_type']) && 'ssh' == $_POST['connection_type']) ) + if ( defined('FTP_SSH') || (defined('FS_METHOD') && 'ssh' == FS_METHOD) ) $credentials['connection_type'] = 'ssh'; - else if ( defined('FTP_SSL') || (isset($_POST['connection_type']) && 'ftps' == $_POST['connection_type']) ) + else if ( defined('FTP_SSL') && 'ftpext' == $type ) //Only the FTP Extension understands SSL $credentials['connection_type'] = 'ftps'; - else if ( !isset($credentials['connection_type']) || (isset($_POST['connection_type']) && 'ftp' == $_POST['connection_type']) ) + else if ( !empty($_POST['connection_type']) ) + $credentials['connection_type'] = $_POST['connection_type']; + else if ( !isset($credentials['connection_type']) ) //All else fails (And its not defaulted to something else saved), Default to FTP $credentials['connection_type'] = 'ftp'; if ( ! $error && @@ -750,9 +754,10 @@ jQuery(function($){ - size="40" />'.__('(Password not shown)').''; ?> + size="40" /> +
@@ -762,14 +767,19 @@ jQuery(function($){
size="40" />
size="40" />
+
-
-
- + + +
+ + +
+