Skip to content

Commit

Permalink
Changed forbidden exec() to Shell
Browse files Browse the repository at this point in the history
  • Loading branch information
dimdimich committed Jan 19, 2024
1 parent cd7ff70 commit 96fa59b
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions Console/Command/InfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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("<info>$description</info>");

$output->writeln("<comment>$response</comment>");


foreach ($result as $line) {
$output->writeln("<comment>$line</comment>");
}
$output->writeln('_____________________________');

return Command::SUCCESS;
} catch (\Exception $e) {
$output->writeln("<error>Error running \"$command\" command</error>");

return Command::FAILURE;
}
}
Expand Down

1 comment on commit 96fa59b

@ci-swissuplabs
Copy link
Contributor

Choose a reason for hiding this comment

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

Good job! All tests are passed!

Please sign in to comment.