X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/fa6ee2c363cdfdebcb4b76e4d9c4347a4cb19065..7f1521bf193b382565eb753043c161f4cb3fcda7:/wp-admin/includes/class-wp-filesystem-ssh2.php diff --git a/wp-admin/includes/class-wp-filesystem-ssh2.php b/wp-admin/includes/class-wp-filesystem-ssh2.php index dbfe7071..0de63548 100644 --- a/wp-admin/includes/class-wp-filesystem-ssh2.php +++ b/wp-admin/includes/class-wp-filesystem-ssh2.php @@ -36,10 +36,11 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base { public $link = false; - public $sftp_link = false; + /** + * @var resource + */ + public $sftp_link; public $keys = false; - public $errors = array(); - public $options = array(); public function __construct($opt='') { $this->method = 'ssh2'; @@ -48,11 +49,11 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base { //Check if possible to use ssh2 functions. if ( ! extension_loaded('ssh2') ) { $this->errors->add('no_ssh2_ext', __('The ssh2 PHP extension is not available')); - return false; + return; } if ( !function_exists('stream_get_contents') ) { $this->errors->add('ssh2_php_requirement', __('The ssh2 PHP extension is available, however, we require the PHP5 function stream_get_contents()')); - return false; + return; } // Set defaults: @@ -66,9 +67,6 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base { else $this->options['hostname'] = $opt['hostname']; - if ( ! empty($opt['base']) ) - $this->wp_base = $opt['base']; - // Check if the options provided are OK. if ( !empty ($opt['public_key']) && !empty ($opt['private_key']) ) { $this->options['public_key'] = $opt['public_key']; @@ -126,6 +124,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base { /** * @param string $command * @param bool $returnbool + * @return bool|string */ public function run_command( $command, $returnbool = false) { @@ -185,14 +184,15 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base { public function cwd() { $cwd = $this->run_command('pwd'); - if ( $cwd ) - $cwd = trailingslashit($cwd); + if ( $cwd ) { + $cwd = trailingslashit( trim( $cwd ) ); + } return $cwd; } /** * @param string $dir - * @return bool + * @return bool|string */ public function chdir($dir) { return $this->run_command('cd ' . $dir, true); @@ -215,7 +215,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base { * @param string $file * @param int $mode * @param bool $recursive - * @return bool + * @return bool|string */ public function chmod($file, $mode = false, $recursive = false) { if ( ! $this->exists($file) )