diff --git a/apps/sharing/lib/Command/GetShares.php b/apps/sharing/lib/Command/GetShares.php index 215e6f2ca4123..6e4158eb55be7 100644 --- a/apps/sharing/lib/Command/GetShares.php +++ b/apps/sharing/lib/Command/GetShares.php @@ -55,7 +55,9 @@ public function execute(InputInterface $input, OutputInterface $output): int { $shares = $this->manager->getShares($this->accessContext, $filterSourceTypeClass, $filterSourceTypeValue, $lastShareID, $limit); $this->dbConnection->commit(); - $output->writeln(json_encode(Share::formatMultiple($this->registry, $this->l10nFactory, $this->urlGenerator, $this->userManager, $shares), JSON_THROW_ON_ERROR)); + + $data = Share::formatMultiple($this->registry, $this->l10nFactory, $this->urlGenerator, $this->userManager, $shares); + $this->writeArrayInOutputFormat($input, $output, $data); return Base::SUCCESS; } catch (Exception $exception) { $this->dbConnection->rollBack(); diff --git a/apps/sharing/lib/Command/SharingBase.php b/apps/sharing/lib/Command/SharingBase.php index b7395b52df1c6..a0a7829d255d9 100644 --- a/apps/sharing/lib/Command/SharingBase.php +++ b/apps/sharing/lib/Command/SharingBase.php @@ -21,13 +21,12 @@ use OCP\IURLGenerator; use OCP\IUserManager; use OCP\L10N\IFactory; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Output\OutputInterface; -abstract class SharingBase extends Command { +abstract class SharingBase extends Base { public ShareAccessContext $accessContext; public function __construct( @@ -71,7 +70,10 @@ protected function wrapExecution(InputInterface $input, OutputInterface $output, $share = $closure(); $this->dbConnection->commit(); - $output->writeln(json_encode($share->format($this->registry, $this->l10nFactory, $this->urlGenerator, $this->userManager), JSON_THROW_ON_ERROR)); + + $data = $share->format($this->registry, $this->l10nFactory, $this->urlGenerator, $this->userManager); + $this->writeArrayInOutputFormat($input, $output, $data); + return Base::SUCCESS; } catch (Exception $exception) { $this->dbConnection->rollBack();