From 59d988a8530300b90013cac57d4ad93a35da30dd Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Tue, 19 May 2026 16:15:04 +0200 Subject: [PATCH 1/2] fix: migrate commands to OC\Core\Command\Base class Signed-off-by: Maksim Sukharev --- REUSE.toml | 6 +++++ lib/Command/Log.php | 4 ++-- lib/Command/Metrics.php | 4 ++-- lib/Command/Reset.php | 4 ++-- lib/Command/SelfTest.php | 4 ++-- lib/Command/Setup.php | 4 ++-- psalm.xml | 1 + tests/stubs/oc_core_command_base.php | 33 ++++++++++++++++++++++++++++ 8 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 tests/stubs/oc_core_command_base.php diff --git a/REUSE.toml b/REUSE.toml index d76c9152..1921fb3b 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -17,6 +17,12 @@ precedence = "aggregate" SPDX-FileCopyrightText = "2023 Nextcloud GmbH and Nextcloud contributors" SPDX-License-Identifier = "AGPL-3.0-or-later" +[[annotations]] +path = ["tests/stubs/oc_core_command_base.php"] +precedence = "aggregate" +SPDX-FileCopyrightText = "2026 Nextcloud GmbH and Nextcloud contributors" +SPDX-License-Identifier = "AGPL-3.0-or-later" + [[annotations]] path = ["img/app.svg", "img/app-dark.svg"] precedence = "aggregate" diff --git a/lib/Command/Log.php b/lib/Command/Log.php index 58ecb29d..7892f1af 100644 --- a/lib/Command/Log.php +++ b/lib/Command/Log.php @@ -8,14 +8,14 @@ namespace OCA\NotifyPush\Command; +use OC\Core\Command\Base; use OCA\NotifyPush\Queue\IQueue; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -class Log extends Command { +class Log extends Base { private $queue; public function __construct( diff --git a/lib/Command/Metrics.php b/lib/Command/Metrics.php index 5d808c89..57d6c9c6 100644 --- a/lib/Command/Metrics.php +++ b/lib/Command/Metrics.php @@ -8,13 +8,13 @@ namespace OCA\NotifyPush\Command; +use OC\Core\Command\Base; use OCA\NotifyPush\Queue\IQueue; use OCA\NotifyPush\Queue\RedisQueue; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class Metrics extends Command { +class Metrics extends Base { private $queue; public function __construct( diff --git a/lib/Command/Reset.php b/lib/Command/Reset.php index 903c0280..6e7c6f54 100644 --- a/lib/Command/Reset.php +++ b/lib/Command/Reset.php @@ -8,12 +8,12 @@ namespace OCA\NotifyPush\Command; +use OC\Core\Command\Base; use OCA\NotifyPush\Queue\IQueue; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class Reset extends Command { +class Reset extends Base { private $queue; public function __construct( diff --git a/lib/Command/SelfTest.php b/lib/Command/SelfTest.php index 7c9d9ac6..7e093ca6 100644 --- a/lib/Command/SelfTest.php +++ b/lib/Command/SelfTest.php @@ -8,12 +8,12 @@ namespace OCA\NotifyPush\Command; +use OC\Core\Command\Base; use OCP\IConfig; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class SelfTest extends Command { +class SelfTest extends Base { private $test; private $config; diff --git a/lib/Command/Setup.php b/lib/Command/Setup.php index 66a69f57..501bf55a 100644 --- a/lib/Command/Setup.php +++ b/lib/Command/Setup.php @@ -8,14 +8,14 @@ namespace OCA\NotifyPush\Command; +use OC\Core\Command\Base; use OCA\NotifyPush\SetupWizard; use OCP\IConfig; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class Setup extends Command { +class Setup extends Base { private $test; private $config; private $setupWizard; diff --git a/psalm.xml b/psalm.xml index 7a444190..85a638b5 100644 --- a/psalm.xml +++ b/psalm.xml @@ -21,6 +21,7 @@ + diff --git a/tests/stubs/oc_core_command_base.php b/tests/stubs/oc_core_command_base.php new file mode 100644 index 00000000..5e9f9a01 --- /dev/null +++ b/tests/stubs/oc_core_command_base.php @@ -0,0 +1,33 @@ + Date: Tue, 19 May 2026 16:18:05 +0200 Subject: [PATCH 2/2] fix(Metrics): improve support for different --output flag Signed-off-by: Maksim Sukharev --- lib/Command/Metrics.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/Command/Metrics.php b/lib/Command/Metrics.php index 57d6c9c6..5697db78 100644 --- a/lib/Command/Metrics.php +++ b/lib/Command/Metrics.php @@ -51,6 +51,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Invalid metrics received from push server'); return 1; } + + // Output in the requested format if different from plain + if ($input->getOption('output') !== self::OUTPUT_FORMAT_PLAIN) { + $this->writeArrayInOutputFormat($input, $output, $metrics); + return 0; + } + $output->writeln('Active connection count: ' . $metrics['active_connection_count']); $output->writeln('Active user count: ' . $metrics['active_user_count']); $output->writeln('Total connection count: ' . $metrics['total_connection_count']);