From 06f4ebce1b1cc8ecd5ddd84f7d2705007a685de3 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 31 May 2015 17:19:42 +0200 Subject: [ticket/13740] CLI installer and fixes [ci skip] PHPBB3-13740 --- .../command/install/config/default_config.php | 103 +++++++++++ .../console/command/install/config/show.php | 131 ++++++++++++++ .../console/command/install/config/validate.php | 132 ++++++++++++++ .../install/console/command/install/install.php | 194 +++++++++++++++++++++ 4 files changed, 560 insertions(+) create mode 100644 phpBB/phpbb/install/console/command/install/config/default_config.php create mode 100644 phpBB/phpbb/install/console/command/install/config/show.php create mode 100644 phpBB/phpbb/install/console/command/install/config/validate.php create mode 100644 phpBB/phpbb/install/console/command/install/install.php (limited to 'phpBB/phpbb/install/console/command') diff --git a/phpBB/phpbb/install/console/command/install/config/default_config.php b/phpBB/phpbb/install/console/command/install/config/default_config.php new file mode 100644 index 0000000000..75c9f94901 --- /dev/null +++ b/phpBB/phpbb/install/console/command/install/config/default_config.php @@ -0,0 +1,103 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\install\console\command\install\config; + +use phpbb\language\language; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Yaml\Yaml; + +class default_config extends \phpbb\console\command\command +{ + /** + * @var language + */ + protected $language; + + /** + * Constructor + * + * @param language $language + */ + public function __construct(language $language) + { + $this->language = $language; + + parent::__construct(new \phpbb\user($language, 'datetime')); + } + + /** + * + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('install:config:default') + ; + } + + /** + * Display the default configuration + * + * @param InputInterface $input An InputInterface instance + * @param OutputInterface $output An OutputInterface instance + * + * @return null + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $default_config = <<writeln($default_config); + } +} diff --git a/phpBB/phpbb/install/console/command/install/config/show.php b/phpBB/phpbb/install/console/command/install/config/show.php new file mode 100644 index 0000000000..4155440fc3 --- /dev/null +++ b/phpBB/phpbb/install/console/command/install/config/show.php @@ -0,0 +1,131 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\install\console\command\install\config; + +use phpbb\install\helper\iohandler\factory; +use phpbb\install\installer; +use phpbb\install\installer_configuration; +use phpbb\language\language; +use Symfony\Component\Config\Definition\Exception\Exception; +use Symfony\Component\Config\Definition\Processor; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\Yaml\Exception\ParseException; +use Symfony\Component\Yaml\Yaml; + +class show extends \phpbb\console\command\command +{ + /** + * @var factory + */ + protected $iohandler_factory; + + /** + * @var installer + */ + protected $installer; + + /** + * @var language + */ + protected $language; + + /** + * Constructor + * + * @param language $language + * @param factory $factory + * @param installer $installer + */ + public function __construct(language $language, factory $factory, installer $installer) + { + $this->iohandler_factory = $factory; + $this->installer = $installer; + $this->language = $language; + + parent::__construct(new \phpbb\user($language, 'datetime')); + } + + /** + * + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('install:config:show') + ->addArgument( + 'config-file', + InputArgument::REQUIRED, + $this->language->lang('CLI_CONFIG_FILE')) + ->setDescription($this->language->lang('CLI_INSTALL_SHOW_CONFIG')) + ; + } + + /** + * Show the validated configuration + * + * @param InputInterface $input An InputInterface instance + * @param OutputInterface $output An OutputInterface instance + * + * @return null + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->iohandler_factory->set_environment('cli'); + + /** @var \phpbb\install\helper\iohandler\cli_iohandler $iohandler */ + $iohandler = $this->iohandler_factory->get(); + $style = new SymfonyStyle($input, $output); + $iohandler->set_style($style, $output); + + $config_file = $input->getArgument('config-file'); + + if (!is_file($config_file)) + { + $iohandler->add_error_message(array('MISSING_FILE', array($config_file))); + + return; + } + + try + { + $config = Yaml::parse(file_get_contents($config_file), true, false); + } + catch (ParseException $e) + { + $iohandler->add_error_message('INVALID_YAML_FILE'); + + return; + } + + $processor = new Processor(); + $configuration = new installer_configuration(); + + try + { + $config = $processor->processConfiguration($configuration, $config); + } + catch (Exception $e) + { + $iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage()); + + return; + } + + $iohandler->add_log_message(Yaml::dump(array('installer' => $config), 10, 4, true, false)); + } +} diff --git a/phpBB/phpbb/install/console/command/install/config/validate.php b/phpBB/phpbb/install/console/command/install/config/validate.php new file mode 100644 index 0000000000..19b6f99a8b --- /dev/null +++ b/phpBB/phpbb/install/console/command/install/config/validate.php @@ -0,0 +1,132 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\install\console\command\install\config; + +use phpbb\install\helper\iohandler\factory; +use phpbb\install\installer; +use phpbb\install\installer_configuration; +use phpbb\language\language; +use Symfony\Component\Config\Definition\Exception\Exception; +use Symfony\Component\Config\Definition\Processor; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\Yaml\Exception\ParseException; +use Symfony\Component\Yaml\Yaml; + +class validate extends \phpbb\console\command\command +{ + /** + * @var factory + */ + protected $iohandler_factory; + + /** + * @var installer + */ + protected $installer; + + /** + * @var language + */ + protected $language; + + /** + * Constructor + * + * @param language $language + * @param factory $factory + * @param installer $installer + */ + public function __construct(language $language, factory $factory, installer $installer) + { + $this->iohandler_factory = $factory; + $this->installer = $installer; + $this->language = $language; + + parent::__construct(new \phpbb\user($language, 'datetime')); + } + + /** + * + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('install:config:validate') + ->addArgument( + 'config-file', + InputArgument::REQUIRED, + $this->language->lang('CLI_CONFIG_FILE')) + ->setDescription($this->language->lang('CLI_INSTALL_VALIDATE_CONFIG')) + ; + } + + /** + * Validate the configuration file + * + * @param InputInterface $input An InputInterface instance + * @param OutputInterface $output An OutputInterface instance + * + * @return null + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->iohandler_factory->set_environment('cli'); + + /** @var \phpbb\install\helper\iohandler\cli_iohandler $iohandler */ + $iohandler = $this->iohandler_factory->get(); + $style = new SymfonyStyle($input, $output); + $iohandler->set_style($style, $output); + + $config_file = $input->getArgument('config-file'); + + if (!is_file($config_file)) + { + $iohandler->add_error_message(array('MISSING_FILE', array($config_file))); + + return 1; + } + + try + { + $config = Yaml::parse(file_get_contents($config_file), true, false); + } + catch (ParseException $e) + { + $iohandler->add_error_message('INVALID_YAML_FILE'); + + return 1; + } + + $processor = new Processor(); + $configuration = new installer_configuration(); + + try + { + $config = $processor->processConfiguration($configuration, $config); + } + catch (Exception $e) + { + $iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage()); + + return 1; + } + + $iohandler->add_success_message('CONFIGURATION_VALID'); + return 0; + } +} diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php new file mode 100644 index 0000000000..d3f6d363f8 --- /dev/null +++ b/phpBB/phpbb/install/console/command/install/install.php @@ -0,0 +1,194 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\install\console\command\install; + +use phpbb\install\exception\installer_exception; +use phpbb\install\helper\iohandler\cli_iohandler; +use phpbb\install\helper\iohandler\factory; +use phpbb\install\installer; +use phpbb\install\installer_configuration; +use phpbb\language\language; +use Symfony\Component\Config\Definition\Exception\Exception; +use Symfony\Component\Config\Definition\Processor; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\Yaml\Exception\ParseException; +use Symfony\Component\Yaml\Yaml; + +class install extends \phpbb\console\command\command +{ + /** + * @var factory + */ + protected $iohandler_factory; + + /** + * @var installer + */ + protected $installer; + + /** + * @var language + */ + protected $language; + + /** + * Constructor + * + * @param language $language + * @param factory $factory + * @param installer $installer + */ + public function __construct(language $language, factory $factory, installer $installer) + { + $this->iohandler_factory = $factory; + $this->installer = $installer; + $this->language = $language; + + parent::__construct(new \phpbb\user($language, 'datetime')); + } + + /** + * + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('install') + ->addArgument( + 'config-file', + InputArgument::REQUIRED, + $this->language->lang('CLI_CONFIG_FILE')) + ->setDescription($this->language->lang('CLI_INSTALL_BOARD')) + ; + } + + /** + * Executes the command install. + * + * Install the board + * + * @param InputInterface $input An InputInterface instance + * @param OutputInterface $output An OutputInterface instance + * + * @return null + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + // @todo check that phpBB is not already installed + + $this->iohandler_factory->set_environment('cli'); + + /** @var \phpbb\install\helper\iohandler\cli_iohandler $iohandler */ + $iohandler = $this->iohandler_factory->get(); + $style = new SymfonyStyle($input, $output); + $iohandler->set_style($style, $output); + + $this->installer->set_iohandler($iohandler); + + $config_file = $input->getArgument('config-file'); + + if (!is_file($config_file)) + { + $iohandler->add_error_message(array('MISSING_FILE', array($config_file))); + + return; + } + + try + { + $config = Yaml::parse(file_get_contents($config_file), true, false); + } + catch (ParseException $e) + { + $iohandler->add_error_message('INVALID_YAML_FILE'); + + return; + } + + $processor = new Processor(); + $configuration = new installer_configuration(); + + try + { + $config = $processor->processConfiguration($configuration, $config); + } + catch (Exception $e) + { + $iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage()); + + return; + } + + $this->register_configuration($iohandler, $config); + + try + { + $this->installer->run(); + } + catch (installer_exception $e) + { + $iohandler->add_error_message($e->getMessage()); + return; + } + } + + /** + * Register the configuration to simulate the forms. + * + * @param cli_iohandler $iohandler + * @param array $config + */ + private function register_configuration(cli_iohandler $iohandler, $config) + { + $iohandler->set_input('admin_name', $config['admin']['name']); + $iohandler->set_input('admin_pass1', $config['admin']['password']); + $iohandler->set_input('admin_pass2', $config['admin']['password']); + $iohandler->set_input('board_email', $config['admin']['email']); + $iohandler->set_input('submit_admin', 'submit'); + + $iohandler->set_input('default_lang', $config['board']['lang']); + $iohandler->set_input('board_name', $config['board']['name']); + $iohandler->set_input('board_description', $config['board']['description']); + $iohandler->set_input('submit_board', 'submit'); + + $iohandler->set_input('dbms', $config['database']['dbms']); + $iohandler->set_input('dbhost', $config['database']['dbhost']); + $iohandler->set_input('dbport', $config['database']['dbport']); + $iohandler->set_input('dbuser', $config['database']['dbuser']); + $iohandler->set_input('dbpasswd', $config['database']['dbpasswd']); + $iohandler->set_input('dbname', $config['database']['dbname']); + $iohandler->set_input('table_prefix', $config['database']['table_prefix']); + $iohandler->set_input('submit_database', 'submit'); + + $iohandler->set_input('email_enable', $config['email']['enabled']); + $iohandler->set_input('smtp_delivery', $config['email']['smtp_delivery']); + $iohandler->set_input('smtp_host', $config['email']['smtp_host']); + $iohandler->set_input('smtp_auth', $config['email']['smtp_auth']); + $iohandler->set_input('smtp_user', $config['email']['smtp_user']); + $iohandler->set_input('smtp_pass', $config['email']['smtp_pass']); + $iohandler->set_input('submit_email', 'submit'); + + $iohandler->set_input('cookie_secure', $config['server']['cookie_secure']); + $iohandler->set_input('server_protocol', $config['server']['server_protocol']); + $iohandler->set_input('force_server_vars', $config['server']['force_server_vars']); + $iohandler->set_input('server_name', $config['server']['server_name']); + $iohandler->set_input('server_port', $config['server']['server_port']); + $iohandler->set_input('script_path', $config['server']['script_path']); + $iohandler->set_input('submit_server', 'submit'); + } +} -- cgit v1.2.1 From 0488c49116f77de55da3ddf36aa2b08f6a5fd085 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Mon, 20 Jul 2015 19:26:07 +0200 Subject: [ticket/13740] Exit from installation if phpBB is already installed PHPBB3-13740 --- .../install/console/command/install/install.php | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'phpBB/phpbb/install/console/command') diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php index d3f6d363f8..e9b4192ded 100644 --- a/phpBB/phpbb/install/console/command/install/install.php +++ b/phpBB/phpbb/install/console/command/install/install.php @@ -14,6 +14,7 @@ namespace phpbb\install\console\command\install; use phpbb\install\exception\installer_exception; +use phpbb\install\helper\install_helper; use phpbb\install\helper\iohandler\cli_iohandler; use phpbb\install\helper\iohandler\factory; use phpbb\install\installer; @@ -40,6 +41,11 @@ class install extends \phpbb\console\command\command */ protected $installer; + /** + * @var install_helper + */ + protected $install_helper; + /** * @var language */ @@ -48,21 +54,22 @@ class install extends \phpbb\console\command\command /** * Constructor * - * @param language $language - * @param factory $factory - * @param installer $installer + * @param language $language + * @param factory $factory + * @param installer $installer + * @param install_helper $install_helper */ - public function __construct(language $language, factory $factory, installer $installer) + public function __construct(language $language, factory $factory, installer $installer, install_helper $install_helper) { $this->iohandler_factory = $factory; $this->installer = $installer; $this->language = $language; + $this->install_helper = $install_helper; parent::__construct(new \phpbb\user($language, 'datetime')); } /** - * * {@inheritdoc} */ protected function configure() @@ -89,8 +96,6 @@ class install extends \phpbb\console\command\command */ protected function execute(InputInterface $input, OutputInterface $output) { - // @todo check that phpBB is not already installed - $this->iohandler_factory->set_environment('cli'); /** @var \phpbb\install\helper\iohandler\cli_iohandler $iohandler */ @@ -102,6 +107,11 @@ class install extends \phpbb\console\command\command $config_file = $input->getArgument('config-file'); + if ($this->install_helper->is_phpbb_installed()) + { + $iohandler->add_error_message('PHPBB_ALREADY_INSTALLED'); + } + if (!is_file($config_file)) { $iohandler->add_error_message(array('MISSING_FILE', array($config_file))); -- cgit v1.2.1 From b2b9fb1df2e6d37c8a327b7b6c380f19e1ff6496 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 21 Jul 2015 14:42:15 +0200 Subject: [ticket/13740] Fix CS and docblocks PHPBB3-13740 --- phpBB/phpbb/install/console/command/install/install.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install/console/command') diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php index e9b4192ded..81ad1039f6 100644 --- a/phpBB/phpbb/install/console/command/install/install.php +++ b/phpBB/phpbb/install/console/command/install/install.php @@ -110,13 +110,15 @@ class install extends \phpbb\console\command\command if ($this->install_helper->is_phpbb_installed()) { $iohandler->add_error_message('PHPBB_ALREADY_INSTALLED'); + + return 1; } if (!is_file($config_file)) { $iohandler->add_error_message(array('MISSING_FILE', array($config_file))); - return; + return 1; } try @@ -127,7 +129,7 @@ class install extends \phpbb\console\command\command { $iohandler->add_error_message('INVALID_YAML_FILE'); - return; + return 1; } $processor = new Processor(); @@ -141,7 +143,7 @@ class install extends \phpbb\console\command\command { $iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage()); - return; + return 1; } $this->register_configuration($iohandler, $config); @@ -153,7 +155,7 @@ class install extends \phpbb\console\command\command catch (installer_exception $e) { $iohandler->add_error_message($e->getMessage()); - return; + return 1; } } -- cgit v1.2.1 From 3a3dd941452eca6f487bb8ab2d21c99f89846f24 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 21 Jul 2015 15:06:15 +0200 Subject: [ticket/13740] Remove default config CLI command PHPBB3-13740 --- .../command/install/config/default_config.php | 103 --------------------- 1 file changed, 103 deletions(-) delete mode 100644 phpBB/phpbb/install/console/command/install/config/default_config.php (limited to 'phpBB/phpbb/install/console/command') diff --git a/phpBB/phpbb/install/console/command/install/config/default_config.php b/phpBB/phpbb/install/console/command/install/config/default_config.php deleted file mode 100644 index 75c9f94901..0000000000 --- a/phpBB/phpbb/install/console/command/install/config/default_config.php +++ /dev/null @@ -1,103 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\install\console\command\install\config; - -use phpbb\language\language; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Yaml\Yaml; - -class default_config extends \phpbb\console\command\command -{ - /** - * @var language - */ - protected $language; - - /** - * Constructor - * - * @param language $language - */ - public function __construct(language $language) - { - $this->language = $language; - - parent::__construct(new \phpbb\user($language, 'datetime')); - } - - /** - * - * {@inheritdoc} - */ - protected function configure() - { - $this - ->setName('install:config:default') - ; - } - - /** - * Display the default configuration - * - * @param InputInterface $input An InputInterface instance - * @param OutputInterface $output An OutputInterface instance - * - * @return null - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $default_config = <<writeln($default_config); - } -} -- cgit v1.2.1 From 079b3d074d905c1982ec22840caae808c3b588f3 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 10 Nov 2015 15:01:18 +0100 Subject: [ticket/14281] Fix installer CLI after recent changes PHPBB3-14281 --- phpBB/phpbb/install/console/command/install/config/show.php | 2 +- phpBB/phpbb/install/console/command/install/install.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install/console/command') diff --git a/phpBB/phpbb/install/console/command/install/config/show.php b/phpBB/phpbb/install/console/command/install/config/show.php index 4155440fc3..587b5f4846 100644 --- a/phpBB/phpbb/install/console/command/install/config/show.php +++ b/phpBB/phpbb/install/console/command/install/config/show.php @@ -96,7 +96,7 @@ class show extends \phpbb\console\command\command if (!is_file($config_file)) { - $iohandler->add_error_message(array('MISSING_FILE', array($config_file))); + $iohandler->add_error_message('MISSING_FILE', array($config_file)); return; } diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php index 81ad1039f6..d76182af92 100644 --- a/phpBB/phpbb/install/console/command/install/install.php +++ b/phpBB/phpbb/install/console/command/install/install.php @@ -116,7 +116,7 @@ class install extends \phpbb\console\command\command if (!is_file($config_file)) { - $iohandler->add_error_message(array('MISSING_FILE', array($config_file))); + $iohandler->add_error_message(array('MISSING_FILE', $config_file)); return 1; } @@ -127,7 +127,7 @@ class install extends \phpbb\console\command\command } catch (ParseException $e) { - $iohandler->add_error_message('INVALID_YAML_FILE'); + $iohandler->add_error_message(array('INVALID_YAML_FILE', $config_file)); return 1; } -- cgit v1.2.1 From a1abf8253f2328f0a5c7b8d7c5885c6cec93f547 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 10 Nov 2015 16:49:30 +0100 Subject: [ticket/14281] Correctly pass parameters to add_error_message PHPBB3-14281 --- phpBB/phpbb/install/console/command/install/config/show.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/console/command') diff --git a/phpBB/phpbb/install/console/command/install/config/show.php b/phpBB/phpbb/install/console/command/install/config/show.php index 587b5f4846..5d82d8d1ef 100644 --- a/phpBB/phpbb/install/console/command/install/config/show.php +++ b/phpBB/phpbb/install/console/command/install/config/show.php @@ -96,7 +96,7 @@ class show extends \phpbb\console\command\command if (!is_file($config_file)) { - $iohandler->add_error_message('MISSING_FILE', array($config_file)); + $iohandler->add_error_message(array('MISSING_FILE', $config_file)); return; } -- cgit v1.2.1 From 73e6e5b77faadbb7676961bf38122d669de111db Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 3 Dec 2015 17:50:29 +0100 Subject: [ticket/13454] Remove unused variables This is the first part of the changes. More to come. PHPBB3-13454 --- phpBB/phpbb/install/console/command/install/config/validate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/console/command') diff --git a/phpBB/phpbb/install/console/command/install/config/validate.php b/phpBB/phpbb/install/console/command/install/config/validate.php index 19b6f99a8b..3bbbc23e34 100644 --- a/phpBB/phpbb/install/console/command/install/config/validate.php +++ b/phpBB/phpbb/install/console/command/install/config/validate.php @@ -117,7 +117,7 @@ class validate extends \phpbb\console\command\command try { - $config = $processor->processConfiguration($configuration, $config); + $processor->processConfiguration($configuration, $config); } catch (Exception $e) { -- cgit v1.2.1 From 5bdfc6167ba13fc525470f89602889ff5bc3ed79 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 25 Feb 2016 22:39:42 +0100 Subject: [ticket/14499] Add command to update the board from CLI PHPBB3-14499 --- .../console/command/install/config/show.php | 12 +- .../console/command/install/config/validate.php | 10 +- .../install/console/command/install/install.php | 2 +- .../install/console/command/update/config/show.php | 123 ++++++++++++++ .../console/command/update/config/validate.php | 124 +++++++++++++++ .../install/console/command/update/update.php | 176 +++++++++++++++++++++ 6 files changed, 427 insertions(+), 20 deletions(-) create mode 100644 phpBB/phpbb/install/console/command/update/config/show.php create mode 100644 phpBB/phpbb/install/console/command/update/config/validate.php create mode 100644 phpBB/phpbb/install/console/command/update/update.php (limited to 'phpBB/phpbb/install/console/command') diff --git a/phpBB/phpbb/install/console/command/install/config/show.php b/phpBB/phpbb/install/console/command/install/config/show.php index 5d82d8d1ef..b6c11956fe 100644 --- a/phpBB/phpbb/install/console/command/install/config/show.php +++ b/phpBB/phpbb/install/console/command/install/config/show.php @@ -14,7 +14,6 @@ namespace phpbb\install\console\command\install\config; use phpbb\install\helper\iohandler\factory; -use phpbb\install\installer; use phpbb\install\installer_configuration; use phpbb\language\language; use Symfony\Component\Config\Definition\Exception\Exception; @@ -33,11 +32,6 @@ class show extends \phpbb\console\command\command */ protected $iohandler_factory; - /** - * @var installer - */ - protected $installer; - /** * @var language */ @@ -48,12 +42,10 @@ class show extends \phpbb\console\command\command * * @param language $language * @param factory $factory - * @param installer $installer */ - public function __construct(language $language, factory $factory, installer $installer) + public function __construct(language $language, factory $factory) { $this->iohandler_factory = $factory; - $this->installer = $installer; $this->language = $language; parent::__construct(new \phpbb\user($language, 'datetime')); @@ -126,6 +118,6 @@ class show extends \phpbb\console\command\command return; } - $iohandler->add_log_message(Yaml::dump(array('installer' => $config), 10, 4, true, false)); + $style->block(Yaml::dump(array('installer' => $config), 10, 4, true, false)); } } diff --git a/phpBB/phpbb/install/console/command/install/config/validate.php b/phpBB/phpbb/install/console/command/install/config/validate.php index 3bbbc23e34..b48a1acbd4 100644 --- a/phpBB/phpbb/install/console/command/install/config/validate.php +++ b/phpBB/phpbb/install/console/command/install/config/validate.php @@ -14,7 +14,6 @@ namespace phpbb\install\console\command\install\config; use phpbb\install\helper\iohandler\factory; -use phpbb\install\installer; use phpbb\install\installer_configuration; use phpbb\language\language; use Symfony\Component\Config\Definition\Exception\Exception; @@ -33,11 +32,6 @@ class validate extends \phpbb\console\command\command */ protected $iohandler_factory; - /** - * @var installer - */ - protected $installer; - /** * @var language */ @@ -48,12 +42,10 @@ class validate extends \phpbb\console\command\command * * @param language $language * @param factory $factory - * @param installer $installer */ - public function __construct(language $language, factory $factory, installer $installer) + public function __construct(language $language, factory $factory) { $this->iohandler_factory = $factory; - $this->installer = $installer; $this->language = $language; parent::__construct(new \phpbb\user($language, 'datetime')); diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php index d76182af92..50c23f6877 100644 --- a/phpBB/phpbb/install/console/command/install/install.php +++ b/phpBB/phpbb/install/console/command/install/install.php @@ -109,7 +109,7 @@ class install extends \phpbb\console\command\command if ($this->install_helper->is_phpbb_installed()) { - $iohandler->add_error_message('PHPBB_ALREADY_INSTALLED'); + $iohandler->add_error_message('INSTALL_PHPBB_INSTALLED'); return 1; } diff --git a/phpBB/phpbb/install/console/command/update/config/show.php b/phpBB/phpbb/install/console/command/update/config/show.php new file mode 100644 index 0000000000..e462763b5d --- /dev/null +++ b/phpBB/phpbb/install/console/command/update/config/show.php @@ -0,0 +1,123 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\install\console\command\update\config; + +use phpbb\install\helper\iohandler\factory; +use phpbb\install\updater_configuration; +use phpbb\language\language; +use Symfony\Component\Config\Definition\Exception\Exception; +use Symfony\Component\Config\Definition\Processor; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\Yaml\Exception\ParseException; +use Symfony\Component\Yaml\Yaml; + +class show extends \phpbb\console\command\command +{ + /** + * @var factory + */ + protected $iohandler_factory; + + /** + * @var language + */ + protected $language; + + /** + * Constructor + * + * @param language $language + * @param factory $factory + */ + public function __construct(language $language, factory $factory) + { + $this->iohandler_factory = $factory; + $this->language = $language; + + parent::__construct(new \phpbb\user($language, 'datetime')); + } + + /** + * + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('update:config:show') + ->addArgument( + 'config-file', + InputArgument::REQUIRED, + $this->language->lang('CLI_CONFIG_FILE')) + ->setDescription($this->language->lang('CLI_INSTALL_SHOW_CONFIG')) + ; + } + + /** + * Show the validated configuration + * + * @param InputInterface $input An InputInterface instance + * @param OutputInterface $output An OutputInterface instance + * + * @return null + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->iohandler_factory->set_environment('cli'); + + /** @var \phpbb\install\helper\iohandler\cli_iohandler $iohandler */ + $iohandler = $this->iohandler_factory->get(); + $style = new SymfonyStyle($input, $output); + $iohandler->set_style($style, $output); + + $config_file = $input->getArgument('config-file'); + + if (!is_file($config_file)) + { + $iohandler->add_error_message(array('MISSING_FILE', $config_file)); + + return; + } + + try + { + $config = Yaml::parse(file_get_contents($config_file), true, false); + } + catch (ParseException $e) + { + $iohandler->add_error_message('INVALID_YAML_FILE'); + + return; + } + + $processor = new Processor(); + $configuration = new updater_configuration(); + + try + { + $config = $processor->processConfiguration($configuration, $config); + } + catch (Exception $e) + { + $iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage()); + + return; + } + + $style->block(Yaml::dump(array('updater' => $config), 10, 4, true, false)); + } +} diff --git a/phpBB/phpbb/install/console/command/update/config/validate.php b/phpBB/phpbb/install/console/command/update/config/validate.php new file mode 100644 index 0000000000..18de5eab46 --- /dev/null +++ b/phpBB/phpbb/install/console/command/update/config/validate.php @@ -0,0 +1,124 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\install\console\command\update\config; + +use phpbb\install\helper\iohandler\factory; +use phpbb\install\updater_configuration; +use phpbb\language\language; +use Symfony\Component\Config\Definition\Exception\Exception; +use Symfony\Component\Config\Definition\Processor; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\Yaml\Exception\ParseException; +use Symfony\Component\Yaml\Yaml; + +class validate extends \phpbb\console\command\command +{ + /** + * @var factory + */ + protected $iohandler_factory; + + /** + * @var language + */ + protected $language; + + /** + * Constructor + * + * @param language $language + * @param factory $factory + */ + public function __construct(language $language, factory $factory) + { + $this->iohandler_factory = $factory; + $this->language = $language; + + parent::__construct(new \phpbb\user($language, 'datetime')); + } + + /** + * + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('update:config:validate') + ->addArgument( + 'config-file', + InputArgument::REQUIRED, + $this->language->lang('CLI_CONFIG_FILE')) + ->setDescription($this->language->lang('CLI_INSTALL_VALIDATE_CONFIG')) + ; + } + + /** + * Validate the configuration file + * + * @param InputInterface $input An InputInterface instance + * @param OutputInterface $output An OutputInterface instance + * + * @return null + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->iohandler_factory->set_environment('cli'); + + /** @var \phpbb\install\helper\iohandler\cli_iohandler $iohandler */ + $iohandler = $this->iohandler_factory->get(); + $style = new SymfonyStyle($input, $output); + $iohandler->set_style($style, $output); + + $config_file = $input->getArgument('config-file'); + + if (!is_file($config_file)) + { + $iohandler->add_error_message(array('MISSING_FILE', array($config_file))); + + return 1; + } + + try + { + $config = Yaml::parse(file_get_contents($config_file), true, false); + } + catch (ParseException $e) + { + $iohandler->add_error_message('INVALID_YAML_FILE'); + + return 1; + } + + $processor = new Processor(); + $configuration = new updater_configuration(); + + try + { + $processor->processConfiguration($configuration, $config); + } + catch (Exception $e) + { + $iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage()); + + return 1; + } + + $iohandler->add_success_message('CONFIGURATION_VALID'); + return 0; + } +} diff --git a/phpBB/phpbb/install/console/command/update/update.php b/phpBB/phpbb/install/console/command/update/update.php new file mode 100644 index 0000000000..8e0d45172c --- /dev/null +++ b/phpBB/phpbb/install/console/command/update/update.php @@ -0,0 +1,176 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\install\console\command\update; + +use phpbb\install\exception\installer_exception; +use phpbb\install\helper\install_helper; +use phpbb\install\helper\iohandler\cli_iohandler; +use phpbb\install\helper\iohandler\factory; +use phpbb\install\installer; +use phpbb\install\updater_configuration; +use phpbb\language\language; +use Symfony\Component\Config\Definition\Exception\Exception; +use Symfony\Component\Config\Definition\Processor; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\Yaml\Exception\ParseException; +use Symfony\Component\Yaml\Yaml; + +class update extends \phpbb\console\command\command +{ + /** + * @var factory + */ + protected $iohandler_factory; + + /** + * @var installer + */ + protected $installer; + + /** + * @var install_helper + */ + protected $install_helper; + + /** + * @var language + */ + protected $language; + + /** + * Constructor + * + * @param language $language + * @param factory $factory + * @param installer $installer + * @param install_helper $install_helper + */ + public function __construct(language $language, factory $factory, installer $installer, install_helper $install_helper) + { + $this->iohandler_factory = $factory; + $this->installer = $installer; + $this->language = $language; + $this->install_helper = $install_helper; + + parent::__construct(new \phpbb\user($language, 'datetime')); + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('update') + ->addArgument( + 'config-file', + InputArgument::REQUIRED, + $this->language->lang('CLI_CONFIG_FILE')) + ->setDescription($this->language->lang('CLI_UPDATE_BOARD')) + ; + } + + /** + * Executes the command update. + * + * Install the board + * + * @param InputInterface $input An InputInterface instance + * @param OutputInterface $output An OutputInterface instance + * + * @return int + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->iohandler_factory->set_environment('cli'); + + /** @var \phpbb\install\helper\iohandler\cli_iohandler $iohandler */ + $iohandler = $this->iohandler_factory->get(); + $style = new SymfonyStyle($input, $output); + $iohandler->set_style($style, $output); + + $this->installer->set_iohandler($iohandler); + + $config_file = $input->getArgument('config-file'); + + if (!$this->install_helper->is_phpbb_installed()) + { + $iohandler->add_error_message('INSTALL_PHPBB_NOT_INSTALLED'); + + return 1; + } + + if (!is_file($config_file)) + { + $iohandler->add_error_message(array('MISSING_FILE', $config_file)); + + return 1; + } + + try + { + $config = Yaml::parse(file_get_contents($config_file), true, false); + } + catch (ParseException $e) + { + $iohandler->add_error_message(array('INVALID_YAML_FILE', $config_file)); + + return 1; + } + + $processor = new Processor(); + $configuration = new updater_configuration(); + + try + { + $config = $processor->processConfiguration($configuration, $config); + } + catch (Exception $e) + { + $iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage()); + + return 1; + } + + $this->register_configuration($iohandler, $config); + + try + { + $this->installer->run(); + } + catch (installer_exception $e) + { + $iohandler->add_error_message($e->getMessage()); + return 1; + } + } + + /** + * Register the configuration to simulate the forms. + * + * @param cli_iohandler $iohandler + * @param array $config + */ + private function register_configuration(cli_iohandler $iohandler, $config) + { + $iohandler->set_input('update_type', $config['type']); + $iohandler->set_input('submit_update', 'submit'); + + $iohandler->set_input('method', '.tar'); + $iohandler->set_input('submit_update_file', 'submit'); + } +} -- cgit v1.2.1 From 8ec1a60156f66dd4fe0f0f6e2cfbee1c79132771 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 28 Feb 2016 20:49:18 +0100 Subject: [ticket/14499] Add missing config settings PHPBB3-14499 --- phpBB/phpbb/install/console/command/update/update.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/console/command') diff --git a/phpBB/phpbb/install/console/command/update/update.php b/phpBB/phpbb/install/console/command/update/update.php index 8e0d45172c..dfac13d5d7 100644 --- a/phpBB/phpbb/install/console/command/update/update.php +++ b/phpBB/phpbb/install/console/command/update/update.php @@ -170,7 +170,10 @@ class update extends \phpbb\console\command\command $iohandler->set_input('update_type', $config['type']); $iohandler->set_input('submit_update', 'submit'); - $iohandler->set_input('method', '.tar'); + $iohandler->set_input('compression_method', '.tar'); + $iohandler->set_input('method', 'direct_file'); $iohandler->set_input('submit_update_file', 'submit'); + + $iohandler->set_input('submit_continue_file_update', 'submit'); } } -- cgit v1.2.1 From 52dffef03cb97a54041b1fba638eafb3ed0a5ce0 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 29 Feb 2016 20:27:12 +0100 Subject: [ticket/14499] Fix wording and comments PHPBB3-14499 --- phpBB/phpbb/install/console/command/update/update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/console/command') diff --git a/phpBB/phpbb/install/console/command/update/update.php b/phpBB/phpbb/install/console/command/update/update.php index dfac13d5d7..116f42f758 100644 --- a/phpBB/phpbb/install/console/command/update/update.php +++ b/phpBB/phpbb/install/console/command/update/update.php @@ -87,7 +87,7 @@ class update extends \phpbb\console\command\command /** * Executes the command update. * - * Install the board + * Update the board * * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance -- cgit v1.2.1 From 9c34594bc374eeeca5d79afe2d3fdffae0cd1553 Mon Sep 17 00:00:00 2001 From: Derek Held Date: Sat, 14 May 2016 09:19:26 -0700 Subject: [ticket/14595] Added smtp_port where places where smtp_host exists. PHPBB3-14595 --- phpBB/phpbb/install/console/command/install/install.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/phpbb/install/console/command') diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php index 50c23f6877..de3a2e2d61 100644 --- a/phpBB/phpbb/install/console/command/install/install.php +++ b/phpBB/phpbb/install/console/command/install/install.php @@ -190,6 +190,7 @@ class install extends \phpbb\console\command\command $iohandler->set_input('email_enable', $config['email']['enabled']); $iohandler->set_input('smtp_delivery', $config['email']['smtp_delivery']); $iohandler->set_input('smtp_host', $config['email']['smtp_host']); + $iohandler->set_input('smtp_port', $config['email']['smtp_port']); $iohandler->set_input('smtp_auth', $config['email']['smtp_auth']); $iohandler->set_input('smtp_user', $config['email']['smtp_user']); $iohandler->set_input('smtp_pass', $config['email']['smtp_pass']); -- cgit v1.2.1 From 65d6e338a99baa2f100d6bd4dea5cd76ac146ac3 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 24 Feb 2016 15:05:01 +0100 Subject: [ticket/14492] Allow specifying extensions to update & install PHPBB3-14492 --- .../phpbb/install/console/command/install/install.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'phpBB/phpbb/install/console/command') diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php index de3a2e2d61..3378f5fdac 100644 --- a/phpBB/phpbb/install/console/command/install/install.php +++ b/phpBB/phpbb/install/console/command/install/install.php @@ -80,6 +80,10 @@ class install extends \phpbb\console\command\command 'config-file', InputArgument::REQUIRED, $this->language->lang('CLI_CONFIG_FILE')) + ->addArgument( + 'install-extensions', + InputArgument::OPTIONAL, + $this->language->lang('CLI_INSTALL_EXTENSIONS')) ->setDescription($this->language->lang('CLI_INSTALL_BOARD')) ; } @@ -147,6 +151,7 @@ class install extends \phpbb\console\command\command } $this->register_configuration($iohandler, $config); + $this->register_install_extensions($iohandler, $input); try { @@ -204,4 +209,17 @@ class install extends \phpbb\console\command\command $iohandler->set_input('script_path', $config['server']['script_path']); $iohandler->set_input('submit_server', 'submit'); } + + /** + * Register extensions to install during installation + * + * @param cli_iohandler $iohandler + * @param InputInterface $input + */ + private function register_install_extensions(cli_iohandler $iohandler, InputInterface $input) + { + $install_extensions = $input->getArgument('install-extensions'); + $install_extensions = !empty($install_extensions) ? explode(',', $install_extensions) : array(); + $iohandler->set_input('install-extensions', $install_extensions); + } } -- cgit v1.2.1 From ffe900c72d358ba0337c607f2ed76f893715f686 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Mar 2016 11:53:20 +0100 Subject: [ticket/14492] Define extensions to install in config not via cli argument PHPBB3-14492 --- .../phpbb/install/console/command/install/install.php | 19 ++----------------- phpBB/phpbb/install/console/command/update/update.php | 3 +++ 2 files changed, 5 insertions(+), 17 deletions(-) (limited to 'phpBB/phpbb/install/console/command') diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php index 3378f5fdac..52a348fe44 100644 --- a/phpBB/phpbb/install/console/command/install/install.php +++ b/phpBB/phpbb/install/console/command/install/install.php @@ -80,10 +80,6 @@ class install extends \phpbb\console\command\command 'config-file', InputArgument::REQUIRED, $this->language->lang('CLI_CONFIG_FILE')) - ->addArgument( - 'install-extensions', - InputArgument::OPTIONAL, - $this->language->lang('CLI_INSTALL_EXTENSIONS')) ->setDescription($this->language->lang('CLI_INSTALL_BOARD')) ; } @@ -151,11 +147,11 @@ class install extends \phpbb\console\command\command } $this->register_configuration($iohandler, $config); - $this->register_install_extensions($iohandler, $input); try { $this->installer->run(); + return 0; } catch (installer_exception $e) { @@ -208,18 +204,7 @@ class install extends \phpbb\console\command\command $iohandler->set_input('server_port', $config['server']['server_port']); $iohandler->set_input('script_path', $config['server']['script_path']); $iohandler->set_input('submit_server', 'submit'); - } - /** - * Register extensions to install during installation - * - * @param cli_iohandler $iohandler - * @param InputInterface $input - */ - private function register_install_extensions(cli_iohandler $iohandler, InputInterface $input) - { - $install_extensions = $input->getArgument('install-extensions'); - $install_extensions = !empty($install_extensions) ? explode(',', $install_extensions) : array(); - $iohandler->set_input('install-extensions', $install_extensions); + $iohandler->set_input('install-extensions', $config['extensions']); } } diff --git a/phpBB/phpbb/install/console/command/update/update.php b/phpBB/phpbb/install/console/command/update/update.php index 116f42f758..e827761d1c 100644 --- a/phpBB/phpbb/install/console/command/update/update.php +++ b/phpBB/phpbb/install/console/command/update/update.php @@ -151,6 +151,7 @@ class update extends \phpbb\console\command\command try { $this->installer->run(); + return 0; } catch (installer_exception $e) { @@ -175,5 +176,7 @@ class update extends \phpbb\console\command\command $iohandler->set_input('submit_update_file', 'submit'); $iohandler->set_input('submit_continue_file_update', 'submit'); + + $iohandler->set_input('update-extensions', $config['extensions']); } } -- cgit v1.2.1