From aa2e70cf0ffb7cbca37fa388d63a9bd6c02dba7e Mon Sep 17 00:00:00 2001 From: Dane Powell Date: Thu, 14 Dec 2023 11:05:13 -0800 Subject: [PATCH] CLI-1130: Workaround for broken Drush SQL import (#1650) * CLI-1130: Workaround for broken Drush SQL import * fix --- src/Helpers/LocalMachineHelper.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Helpers/LocalMachineHelper.php b/src/Helpers/LocalMachineHelper.php index 5ea4e074d..230ac7bc7 100644 --- a/src/Helpers/LocalMachineHelper.php +++ b/src/Helpers/LocalMachineHelper.php @@ -56,7 +56,7 @@ public function commandExists(mixed $command): bool { return (bool) $this->installedBinaries[$command]; } $osCommand = OsInfo::isWindows() ? ['where', $command] : ['which', $command]; - $exists = $this->execute($osCommand, NULL, NULL, FALSE)->isSuccessful(); + $exists = $this->execute($osCommand, NULL, NULL, FALSE, NULL, NULL, FALSE)->isSuccessful(); $this->installedBinaries[$command] = $exists; return $exists; } @@ -71,13 +71,10 @@ public function checkRequiredBinariesExist(array $binaries = []): void { /** * Executes a buffered command. - * - * @param array $cmd The command to execute. - * @param null $callback A function to run while waiting for the process to complete. */ - public function execute(array $cmd, callable $callback = NULL, string $cwd = NULL, ?bool $printOutput = TRUE, float $timeout = NULL, array $env = NULL): Process { + public function execute(array $cmd, callable $callback = NULL, string $cwd = NULL, ?bool $printOutput = TRUE, float $timeout = NULL, array $env = NULL, bool $stdin = TRUE): Process { $process = new Process($cmd); - $process = $this->configureProcess($process, $cwd, $printOutput, $timeout, $env); + $process = $this->configureProcess($process, $cwd, $printOutput, $timeout, $env, $stdin); return $this->executeProcess($process, $callback, $printOutput); } @@ -106,8 +103,8 @@ public function executeFromCmd(string $cmd, callable $callback = NULL, string $c * @param string|null $cwd * @param array|null $env */ - private function configureProcess(Process $process, string $cwd = NULL, ?bool $printOutput = TRUE, float $timeout = NULL, array $env = NULL): Process { - if (function_exists('posix_isatty') && !@posix_isatty(STDIN)) { + private function configureProcess(Process $process, string $cwd = NULL, ?bool $printOutput = TRUE, float $timeout = NULL, array $env = NULL, bool $stdin = TRUE): Process { + if (function_exists('posix_isatty') && !@posix_isatty(STDIN) && $stdin) { $process->setInput(STDIN); } if ($cwd) {