]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/class-wp-filesystem-ssh2.php
WordPress 4.2
[autoinstalls/wordpress.git] / wp-admin / includes / class-wp-filesystem-ssh2.php
index dbfe707132496389f605ede5723d1e4a35c01918..0de635481a694154fce816c8662b00bddc0c02c1 100644 (file)
 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 <code>stream_get_contents()</code>'));
-                       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) )