From 96fa59bab114025df38806d15cb2bff4d99b52be Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 19 Jan 2024 14:49:32 +0200 Subject: [PATCH] Changed forbidden exec() to Shell --- Console/Command/InfoCommand.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Console/Command/InfoCommand.php b/Console/Command/InfoCommand.php index 2009937..aace90e 100644 --- a/Console/Command/InfoCommand.php +++ b/Console/Command/InfoCommand.php @@ -86,22 +86,21 @@ protected function execute(InputInterface $input, OutputInterface $output) private function getCommandInfo(InputInterface $input, OutputInterface $output, $command, $description) { try { - $result = null; - $exitCode = null; - exec($command, $result, $exitCode); - + $result = []; + + $shellExecute = \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Framework\Shell::class); + $response = $shellExecute->execute($command, $result); + $output->writeln("$description"); + + $output->writeln("$response"); - - foreach ($result as $line) { - $output->writeln("$line"); - } $output->writeln('_____________________________'); - + return Command::SUCCESS; } catch (\Exception $e) { $output->writeln("Error running \"$command\" command"); - + return Command::FAILURE; } }