More Symfony 5 compatibility fixes (#1971)

* Make Rsync compatible with symfony/process v5

* Make Ssh client compatible with symfony/process v5

* Add CHANGELOG entry
This commit is contained in:
Arnout Boks 2019-12-17 15:43:48 +02:00 committed by Anton Medvedev
parent 97c63e91cc
commit 5f32216c11
3 changed files with 18 additions and 4 deletions

View File

@ -6,6 +6,7 @@
### Fixed
- Fixed compatibility with Symfony 4.x
- Fixed more incompatibilities with Symfony 5
## v6.7.1

View File

@ -68,7 +68,7 @@ class Client
$command = escapeshellarg($command);
$ssh = "ssh $sshArguments $host $command";
$process = new Process($ssh);
$process = $this->createProcess($ssh);
$process
->setTimeout($config['timeout'])
->setTty(true)
@ -89,7 +89,7 @@ class Client
$ssh = "ssh $sshArguments $host $become '$shellCommand; printf \"[exit_code:%s]\" $?;'";
}
$process = new Process($ssh);
$process = $this->createProcess($ssh);
$process
->setInput($command)
->setTimeout($config['timeout']);
@ -146,7 +146,7 @@ class Client
private function isMultiplexingInitialized(Host $host, Arguments $sshArguments)
{
$process = new Process("ssh -O check $sshArguments $host 2>&1");
$process = $this->createProcess("ssh -O check $sshArguments $host 2>&1");
$process->run();
return (bool)preg_match('/Master running/', $process->getOutput());
}
@ -174,4 +174,13 @@ class Client
}
return $output;
}
private function createProcess($command)
{
if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
return Process::fromShellCommandline($command);
} else {
return new Process($command);
}
}
}

View File

@ -43,7 +43,11 @@ class Rsync
$this->pop->command($hostname, $rsync);
$process = new Process($rsync);
if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
$process = Process::fromShellCommandline($rsync);
} else {
$process = new Process($rsync);
}
$process
->setTimeout($config['timeout'])
->mustRun($this->pop->callback($hostname));