From b17fa7dfa588fc191f4ed268b88dcaec40294acb Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 8 Dec 2016 14:24:02 -0800 Subject: [ticket/14895] Use SymfonyStyle in all CLI PHPBB3-14895 --- phpBB/phpbb/console/command/extension/disable.php | 7 ++++-- phpBB/phpbb/console/command/extension/enable.php | 7 ++++-- phpBB/phpbb/console/command/extension/purge.php | 7 ++++-- phpBB/phpbb/console/command/extension/show.php | 28 ++++++++--------------- 4 files changed, 25 insertions(+), 24 deletions(-) (limited to 'phpBB/phpbb/console/command/extension') diff --git a/phpBB/phpbb/console/command/extension/disable.php b/phpBB/phpbb/console/command/extension/disable.php index 1eee16cbd9..d022755753 100644 --- a/phpBB/phpbb/console/command/extension/disable.php +++ b/phpBB/phpbb/console/command/extension/disable.php @@ -15,6 +15,7 @@ namespace phpbb\console\command\extension; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; class disable extends command { @@ -33,19 +34,21 @@ class disable extends command protected function execute(InputInterface $input, OutputInterface $output) { + $io = new SymfonyStyle($input, $output); + $name = $input->getArgument('extension-name'); $this->manager->disable($name); $this->manager->load_extensions(); if ($this->manager->is_enabled($name)) { - $output->writeln('' . $this->user->lang('CLI_EXTENSION_DISABLE_FAILURE', $name) . ''); + $io->error($this->user->lang('CLI_EXTENSION_DISABLE_FAILURE', $name)); return 1; } else { $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_DISABLE', time(), array($name)); - $output->writeln('' . $this->user->lang('CLI_EXTENSION_DISABLE_SUCCESS', $name) . ''); + $io->success($this->user->lang('CLI_EXTENSION_DISABLE_SUCCESS', $name)); return 0; } } diff --git a/phpBB/phpbb/console/command/extension/enable.php b/phpBB/phpbb/console/command/extension/enable.php index 59ff11e9b7..14077d688b 100644 --- a/phpBB/phpbb/console/command/extension/enable.php +++ b/phpBB/phpbb/console/command/extension/enable.php @@ -15,6 +15,7 @@ namespace phpbb\console\command\extension; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; class enable extends command { @@ -33,6 +34,8 @@ class enable extends command protected function execute(InputInterface $input, OutputInterface $output) { + $io = new SymfonyStyle($input, $output); + $name = $input->getArgument('extension-name'); $this->manager->enable($name); $this->manager->load_extensions(); @@ -40,12 +43,12 @@ class enable extends command if ($this->manager->is_enabled($name)) { $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($name)); - $output->writeln('' . $this->user->lang('CLI_EXTENSION_ENABLE_SUCCESS', $name) . ''); + $io->success($this->user->lang('CLI_EXTENSION_ENABLE_SUCCESS', $name)); return 0; } else { - $output->writeln('' . $this->user->lang('CLI_EXTENSION_ENABLE_FAILURE', $name) . ''); + $io->error($this->user->lang('CLI_EXTENSION_ENABLE_FAILURE', $name)); return 1; } } diff --git a/phpBB/phpbb/console/command/extension/purge.php b/phpBB/phpbb/console/command/extension/purge.php index 517e9a74c9..25bde503f7 100644 --- a/phpBB/phpbb/console/command/extension/purge.php +++ b/phpBB/phpbb/console/command/extension/purge.php @@ -15,6 +15,7 @@ namespace phpbb\console\command\extension; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; class purge extends command { @@ -33,19 +34,21 @@ class purge extends command protected function execute(InputInterface $input, OutputInterface $output) { + $io = new SymfonyStyle($input, $output); + $name = $input->getArgument('extension-name'); $this->manager->purge($name); $this->manager->load_extensions(); if ($this->manager->is_enabled($name)) { - $output->writeln('' . $this->user->lang('CLI_EXTENSION_PURGE_FAILURE', $name) . ''); + $io->error($this->user->lang('CLI_EXTENSION_PURGE_FAILURE', $name)); return 1; } else { $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_PURGE', time(), array($name)); - $output->writeln('' . $this->user->lang('CLI_EXTENSION_PURGE_SUCCESS', $name) . ''); + $io->success($this->user->lang('CLI_EXTENSION_PURGE_SUCCESS', $name)); return 0; } } diff --git a/phpBB/phpbb/console/command/extension/show.php b/phpBB/phpbb/console/command/extension/show.php index f9322034d7..7bad0c0a5a 100644 --- a/phpBB/phpbb/console/command/extension/show.php +++ b/phpBB/phpbb/console/command/extension/show.php @@ -14,6 +14,7 @@ namespace phpbb\console\command\extension; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; class show extends command { @@ -27,36 +28,27 @@ class show extends command protected function execute(InputInterface $input, OutputInterface $output) { + $io = new SymfonyStyle($input, $output); + $this->manager->load_extensions(); $all = array_keys($this->manager->all_available()); if (empty($all)) { - $output->writeln('' . $this->user->lang('CLI_EXTENSION_NOT_FOUND') . ''); + $io->note($this->user->lang('CLI_EXTENSION_NOT_FOUND')); return 3; } $enabled = array_keys($this->manager->all_enabled()); - $this->print_extension_list($output, $this->user->lang('CLI_EXTENSIONS_ENABLED') . $this->user->lang('COLON'), $enabled); - - $output->writeln(''); + $io->section($this->user->lang('CLI_EXTENSIONS_ENABLED')); + $io->listing($enabled); $disabled = array_keys($this->manager->all_disabled()); - $this->print_extension_list($output, $this->user->lang('CLI_EXTENSIONS_DISABLED') . $this->user->lang('COLON'), $disabled); - - $output->writeln(''); + $io->section($this->user->lang('CLI_EXTENSIONS_DISABLED')); + $io->listing($disabled); $purged = array_diff($all, $enabled, $disabled); - $this->print_extension_list($output, $this->user->lang('CLI_EXTENSIONS_AVAILABLE') . $this->user->lang('COLON'), $purged); - } - - protected function print_extension_list(OutputInterface $output, $type, array $extensions) - { - $output->writeln("$type"); - - foreach ($extensions as $extension) - { - $output->writeln(" - $extension"); - } + $io->section($this->user->lang('CLI_EXTENSIONS_AVAILABLE')); + $io->listing($purged); } } -- cgit v1.2.1 From 891aab05935e9ebc237a83cef0b248998cb5fccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Sat, 11 Mar 2017 20:34:40 +0100 Subject: [ticket/15123] add check before enable or disable extension PHPBB3-15123 --- phpBB/phpbb/console/command/extension/disable.php | 7 +++++++ phpBB/phpbb/console/command/extension/enable.php | 7 +++++++ 2 files changed, 14 insertions(+) (limited to 'phpBB/phpbb/console/command/extension') diff --git a/phpBB/phpbb/console/command/extension/disable.php b/phpBB/phpbb/console/command/extension/disable.php index d022755753..be5c77a9a0 100644 --- a/phpBB/phpbb/console/command/extension/disable.php +++ b/phpBB/phpbb/console/command/extension/disable.php @@ -37,6 +37,13 @@ class disable extends command $io = new SymfonyStyle($input, $output); $name = $input->getArgument('extension-name'); + + if (!$this->manager->is_enabled($name)) + { + $io->error($this->user->lang('CLI_EXTENSION_ALREADY_DISABLED', $name)); + return 1; + } + $this->manager->disable($name); $this->manager->load_extensions(); diff --git a/phpBB/phpbb/console/command/extension/enable.php b/phpBB/phpbb/console/command/extension/enable.php index 14077d688b..2de7498c71 100644 --- a/phpBB/phpbb/console/command/extension/enable.php +++ b/phpBB/phpbb/console/command/extension/enable.php @@ -37,6 +37,13 @@ class enable extends command $io = new SymfonyStyle($input, $output); $name = $input->getArgument('extension-name'); + + if ($this->manager->is_enabled($name)) + { + $io->error($this->user->lang('CLI_EXTENSION_ALREADY_ENABLED', $name)); + return 1; + } + $this->manager->enable($name); $this->manager->load_extensions(); -- cgit v1.2.1 From 68c167fe7a5f0c86d97c9c3dda30f66d9df5b032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Sat, 11 Mar 2017 20:39:16 +0100 Subject: [ticket/15123] removed blank spaces PHPBB3-15123 --- phpBB/phpbb/console/command/extension/disable.php | 2 +- phpBB/phpbb/console/command/extension/enable.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/console/command/extension') diff --git a/phpBB/phpbb/console/command/extension/disable.php b/phpBB/phpbb/console/command/extension/disable.php index be5c77a9a0..323f9b6d83 100644 --- a/phpBB/phpbb/console/command/extension/disable.php +++ b/phpBB/phpbb/console/command/extension/disable.php @@ -43,7 +43,7 @@ class disable extends command $io->error($this->user->lang('CLI_EXTENSION_ALREADY_DISABLED', $name)); return 1; } - + $this->manager->disable($name); $this->manager->load_extensions(); diff --git a/phpBB/phpbb/console/command/extension/enable.php b/phpBB/phpbb/console/command/extension/enable.php index 2de7498c71..e6b5f66c7f 100644 --- a/phpBB/phpbb/console/command/extension/enable.php +++ b/phpBB/phpbb/console/command/extension/enable.php @@ -43,7 +43,7 @@ class enable extends command $io->error($this->user->lang('CLI_EXTENSION_ALREADY_ENABLED', $name)); return 1; } - + $this->manager->enable($name); $this->manager->load_extensions(); -- cgit v1.2.1 From 8994295f2b7d5b2beece7bbd8f7a2861fa15625d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Sat, 11 Mar 2017 23:03:31 +0100 Subject: [ticket/15123] modified language string PHPBB3-15123 --- phpBB/phpbb/console/command/extension/disable.php | 2 +- phpBB/phpbb/console/command/extension/enable.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/console/command/extension') diff --git a/phpBB/phpbb/console/command/extension/disable.php b/phpBB/phpbb/console/command/extension/disable.php index 323f9b6d83..05f7ce9704 100644 --- a/phpBB/phpbb/console/command/extension/disable.php +++ b/phpBB/phpbb/console/command/extension/disable.php @@ -40,7 +40,7 @@ class disable extends command if (!$this->manager->is_enabled($name)) { - $io->error($this->user->lang('CLI_EXTENSION_ALREADY_DISABLED', $name)); + $io->error($this->user->lang('CLI_EXTENSION_DISABLE_DISABLED', $name)); return 1; } diff --git a/phpBB/phpbb/console/command/extension/enable.php b/phpBB/phpbb/console/command/extension/enable.php index e6b5f66c7f..c7c336cdc9 100644 --- a/phpBB/phpbb/console/command/extension/enable.php +++ b/phpBB/phpbb/console/command/extension/enable.php @@ -40,7 +40,7 @@ class enable extends command if ($this->manager->is_enabled($name)) { - $io->error($this->user->lang('CLI_EXTENSION_ALREADY_ENABLED', $name)); + $io->error($this->user->lang('CLI_EXTENSION_ENABLE_ENABLED', $name)); return 1; } -- cgit v1.2.1 From 9b3609d6f60af328e6681146014453da0af4ee01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Sun, 12 Mar 2017 22:44:18 +0100 Subject: [ticket/15123] modified language strings PHPBB3-15123 --- phpBB/phpbb/console/command/extension/disable.php | 2 +- phpBB/phpbb/console/command/extension/enable.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/console/command/extension') diff --git a/phpBB/phpbb/console/command/extension/disable.php b/phpBB/phpbb/console/command/extension/disable.php index 05f7ce9704..12674c16cb 100644 --- a/phpBB/phpbb/console/command/extension/disable.php +++ b/phpBB/phpbb/console/command/extension/disable.php @@ -40,7 +40,7 @@ class disable extends command if (!$this->manager->is_enabled($name)) { - $io->error($this->user->lang('CLI_EXTENSION_DISABLE_DISABLED', $name)); + $io->error($this->user->lang('CLI_EXTENSION_DISABLED', $name)); return 1; } diff --git a/phpBB/phpbb/console/command/extension/enable.php b/phpBB/phpbb/console/command/extension/enable.php index c7c336cdc9..079e4ce1f6 100644 --- a/phpBB/phpbb/console/command/extension/enable.php +++ b/phpBB/phpbb/console/command/extension/enable.php @@ -40,7 +40,7 @@ class enable extends command if ($this->manager->is_enabled($name)) { - $io->error($this->user->lang('CLI_EXTENSION_ENABLE_ENABLED', $name)); + $io->error($this->user->lang('CLI_EXTENSION_ENABLED', $name)); return 1; } -- cgit v1.2.1 From 45f0adcd0a4e6c7e43183fe641fa03ef2d90d45b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Sun, 12 Mar 2017 22:45:33 +0100 Subject: [ticket/15123] modified return error codes PHPBB3-15123 --- phpBB/phpbb/console/command/extension/disable.php | 2 +- phpBB/phpbb/console/command/extension/enable.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/console/command/extension') diff --git a/phpBB/phpbb/console/command/extension/disable.php b/phpBB/phpbb/console/command/extension/disable.php index 12674c16cb..b2e10fb960 100644 --- a/phpBB/phpbb/console/command/extension/disable.php +++ b/phpBB/phpbb/console/command/extension/disable.php @@ -41,7 +41,7 @@ class disable extends command if (!$this->manager->is_enabled($name)) { $io->error($this->user->lang('CLI_EXTENSION_DISABLED', $name)); - return 1; + return 2; } $this->manager->disable($name); diff --git a/phpBB/phpbb/console/command/extension/enable.php b/phpBB/phpbb/console/command/extension/enable.php index 079e4ce1f6..a8312d5c15 100644 --- a/phpBB/phpbb/console/command/extension/enable.php +++ b/phpBB/phpbb/console/command/extension/enable.php @@ -41,7 +41,7 @@ class enable extends command if ($this->manager->is_enabled($name)) { $io->error($this->user->lang('CLI_EXTENSION_ENABLED', $name)); - return 1; + return 2; } $this->manager->enable($name); -- cgit v1.2.1 From aa23af38d4d3a13918e859005277955debd76acd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Thu, 7 Sep 2017 12:53:44 +0200 Subject: [ticket/15349] Check if extension is enableable before enable PHPBB3-15346 --- phpBB/phpbb/console/command/extension/enable.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'phpBB/phpbb/console/command/extension') diff --git a/phpBB/phpbb/console/command/extension/enable.php b/phpBB/phpbb/console/command/extension/enable.php index a8312d5c15..b35fb9c4c6 100644 --- a/phpBB/phpbb/console/command/extension/enable.php +++ b/phpBB/phpbb/console/command/extension/enable.php @@ -37,6 +37,13 @@ class enable extends command $io = new SymfonyStyle($input, $output); $name = $input->getArgument('extension-name'); + $extension = $this->manager->get_extension($name); + + if (!$extension->is_enableable()) + { + $io->error($this->user->lang('CLI_EXTENSION_NOT_ENABLEABLE', $name)); + return 1; + } if ($this->manager->is_enabled($name)) { -- cgit v1.2.1 From bf289de26f137bfe50608b6f9c549b306ede5b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Thu, 7 Sep 2017 12:54:13 +0200 Subject: [ticket/15349] Return 1 instead of 2 in case of error PHPBB3-15346 --- phpBB/phpbb/console/command/extension/enable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/console/command/extension') diff --git a/phpBB/phpbb/console/command/extension/enable.php b/phpBB/phpbb/console/command/extension/enable.php index b35fb9c4c6..f92de0069c 100644 --- a/phpBB/phpbb/console/command/extension/enable.php +++ b/phpBB/phpbb/console/command/extension/enable.php @@ -48,7 +48,7 @@ class enable extends command if ($this->manager->is_enabled($name)) { $io->error($this->user->lang('CLI_EXTENSION_ENABLED', $name)); - return 2; + return 1; } $this->manager->enable($name); -- cgit v1.2.1 From 03b3b38db17c5fc554f54aed3f3fc1941279a04e Mon Sep 17 00:00:00 2001 From: hubaishan Date: Wed, 1 Nov 2017 08:48:21 +0300 Subject: [ticket/15433] Fix phpbbcli can enable non-existent extension Fix phpbbcli can enable non-existent extension PHPBB3-15433 --- phpBB/phpbb/console/command/extension/enable.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'phpBB/phpbb/console/command/extension') diff --git a/phpBB/phpbb/console/command/extension/enable.php b/phpBB/phpbb/console/command/extension/enable.php index f92de0069c..a6f5b10e86 100644 --- a/phpBB/phpbb/console/command/extension/enable.php +++ b/phpBB/phpbb/console/command/extension/enable.php @@ -37,6 +37,13 @@ class enable extends command $io = new SymfonyStyle($input, $output); $name = $input->getArgument('extension-name'); + + if (!$this->manager->is_available($name)) + { + $io->error($this->user->lang('CLI_EXTENSION_NOT_EXIST', $name)); + return 1; + } + $extension = $this->manager->get_extension($name); if (!$extension->is_enableable()) -- cgit v1.2.1