diff options
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/config/installer/container/services_install_console.yml | 1 | ||||
-rw-r--r-- | phpBB/config/installer/container/services_install_controller.yml | 1 | ||||
-rw-r--r-- | phpBB/config/installer/container/services_installer.yml | 6 | ||||
-rw-r--r-- | phpBB/language/en/install.php | 3 | ||||
-rw-r--r-- | phpBB/phpbb/install/console/command/install/install.php | 24 | ||||
-rw-r--r-- | phpBB/phpbb/install/controller/helper.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/install/controller/install.php | 18 | ||||
-rw-r--r-- | phpBB/phpbb/install/helper/install_helper.php | 60 |
8 files changed, 103 insertions, 12 deletions
diff --git a/phpBB/config/installer/container/services_install_console.yml b/phpBB/config/installer/container/services_install_console.yml index 9a4808b6aa..5a1e898754 100644 --- a/phpBB/config/installer/container/services_install_console.yml +++ b/phpBB/config/installer/container/services_install_console.yml @@ -21,6 +21,7 @@ services: - @language - @installer.helper.iohandler_factory - @installer.installer.install + - @installer.helper.install_helper tags: - { name: console.installer.command } diff --git a/phpBB/config/installer/container/services_install_controller.yml b/phpBB/config/installer/container/services_install_controller.yml index c8d140aa5f..7acc7025a6 100644 --- a/phpBB/config/installer/container/services_install_controller.yml +++ b/phpBB/config/installer/container/services_install_controller.yml @@ -30,3 +30,4 @@ services: - @template - @request - @installer.installer.install + - @installer.helper.install_helper diff --git a/phpBB/config/installer/container/services_installer.yml b/phpBB/config/installer/container/services_installer.yml index 8e19be5c0c..62137aa9d8 100644 --- a/phpBB/config/installer/container/services_installer.yml +++ b/phpBB/config/installer/container/services_installer.yml @@ -56,6 +56,12 @@ services: - %core.root_path% - %core.php_ext% + installer.helper.install_helper: + class: phpbb\install\helper\install_helper + arguments: + - %core.root_path% + - %core.php_ext% + # -------- Installer -------------------------------- installer.module_base: abstract: true diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index f050d49ebd..10d25b0311 100644 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -113,7 +113,8 @@ $lang = array_merge($lang, array( // General error messages $lang = array_merge($lang, array( - 'INST_ERR_MISSING_DATA' => 'You must fill out all fields in this block.', + 'INST_ERR_MISSING_DATA' => 'You must fill out all fields in this block.', + 'PHPBB_ALREADY_INSTALLED' => 'phpBB is already installed.' )); // Data obtaining translations 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; @@ -41,6 +42,11 @@ class install extends \phpbb\console\command\command protected $installer; /** + * @var install_helper + */ + protected $install_helper; + + /** * @var language */ protected $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))); diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index 5ef98ac2bb..a16298c525 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -219,7 +219,7 @@ class helper protected function render_language_select() { $langs = $this->lang_helper->get_available_languages(); - // @todo + // @todo Implement language change option } /** diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index c742906305..5cd42fcb84 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -13,7 +13,9 @@ namespace phpbb\install\controller; +use phpbb\exception\http_exception; use phpbb\install\helper\config; +use phpbb\install\helper\install_helper; use phpbb\install\helper\navigation\navigation_provider; use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpFoundation\Response; @@ -70,6 +72,11 @@ class install protected $installer; /** + * @var install_helper + */ + protected $install_helper; + + /** * Constructor * * @param helper $helper @@ -80,8 +87,9 @@ class install * @param template $template * @param request_interface $request * @param installer $installer + * @param install_helper $install_helper */ - public function __construct(helper $helper, config $install_config, factory $factory, navigation_provider $nav_provider, language $language, template $template, request_interface $request, installer $installer) + public function __construct(helper $helper, config $install_config, factory $factory, navigation_provider $nav_provider, language $language, template $template, request_interface $request, installer $installer, install_helper $install_helper) { $this->controller_helper = $helper; $this->installer_config = $install_config; @@ -91,6 +99,7 @@ class install $this->template = $template; $this->request = $request; $this->installer = $installer; + $this->install_helper = $install_helper; } /** @@ -100,8 +109,6 @@ class install */ public function handle() { - // @todo check that phpBB is not already installed - $this->template->assign_vars(array( 'U_ACTION' => $this->controller_helper->route('phpbb_installer_install'), )); @@ -124,6 +131,11 @@ class install /** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */ $iohandler = $this->iohandler_factory->get(); + if ($this->install_helper->is_phpbb_installed()) + { + throw new http_exception(404, 'PAGE_NOT_FOUND'); + } + // Set active navigation stage if (isset($nav_data['active']) && is_array($nav_data['active'])) { diff --git a/phpBB/phpbb/install/helper/install_helper.php b/phpBB/phpbb/install/helper/install_helper.php new file mode 100644 index 0000000000..c1506de5bf --- /dev/null +++ b/phpBB/phpbb/install/helper/install_helper.php @@ -0,0 +1,60 @@ +<?php +/** + * + * This file is part of the phpBB Forum Software package. + * + * @copyright (c) phpBB Limited <https://www.phpbb.com> + * @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\helper; + +/** + * General helper functionality for the installer + */ +class install_helper +{ + /** + * @var string + */ + protected $php_ext; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * Constructor + * + * @param string $phpbb_root_path path to phpBB's root + * @param string $php_ext Extension of PHP files + */ + public function __construct($phpbb_root_path, $php_ext) + { + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + } + + /** + * Check whether phpBB is installed. + * + * @return bool + */ + public function is_phpbb_installed() + { + $config_path = $this->phpbb_root_path . 'config' . $this->php_ext; + $install_lock_path = $this->phpbb_root_path . 'cache/install_lock'; + + if (file_exists($config_path) && !file_exists($install_lock_path)) + { + include_once $config_path; + } + + return defined('PHPBB_INSTALLED'); + } +} |