Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix phpseclib class namespace in Varien_Io_Sftp #3008

Merged
merged 1 commit into from
Feb 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions lib/Varien/Io/Sftp.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

require_once('phpseclib/Net/SFTP.php');

/**
* Sftp client interface
*
Expand All @@ -35,7 +33,7 @@ class Varien_Io_Sftp extends Varien_Io_Abstract implements Varien_Io_Interface
public const SSH2_PORT = 22;

/**
* @var phpseclib\Net\SFTP $_connection
* @var \phpseclib3\Net\SFTP $_connection
*/
protected $_connection = null;

Expand All @@ -60,7 +58,7 @@ public function open(array $args = [])
$host = $args['host'];
$port = self::SSH2_PORT;
}
$this->_connection = new phpseclib\Net\SFTP($host, $port, $args['timeout']);
$this->_connection = new \phpseclib3\Net\SFTP($host, $port, $args['timeout']);
if (!$this->_connection->login($args['username'], $args['password'])) {
throw new Exception(sprintf(__("Unable to open SFTP connection as %s@%s", $args['username'], $args['host'])));
}
Expand Down Expand Up @@ -117,7 +115,7 @@ public function rmdir($dir, $recursive = false)
$list = $this->_connection->nlist();
if (!count($list)) {
// Go back
$this->_connection->chdir($pwd);
$this->_connection->chdir($cwd);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better to change line 111 instead:

from $cwd = $this->_connection->pwd();
to $pwd = $this->_connection->pwd();

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think pwd means "print working directory", and cwd means "current working directory". So cwd is the value resulting from calling pwd().

return $this->rmdir($dir, false);
} else {
foreach ($list as $filename) {
Expand All @@ -129,7 +127,7 @@ public function rmdir($dir, $recursive = false)
}
}
}
$no_errors = $no_errors && ($this->_connection->chdir($pwd) && $this->_connection->rmdir($dir));
$no_errors = $no_errors && ($this->_connection->chdir($cwd) && $this->_connection->rmdir($dir));
return $no_errors;
} else {
return $this->_connection->rmdir($dir);
Expand Down Expand Up @@ -234,6 +232,6 @@ public function rawls()
*/
public function writeFile($filename, $src)
{
return $this->_connection->put($filename, $src, phpseclib\Net\SFTP::SOURCE_LOCAL_FILE);
return $this->_connection->put($filename, $src, \phpseclib3\Net\SFTP::SOURCE_LOCAL_FILE);
}
}